🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to unload script from Lua?

Started by
5 comments, last by CodeZ 21 years ago
Is it possible to UnLoad a script from luas memory? If not how many functions can you load into memory with lua_dofile before something bad happends Thanks!
Advertisement
well theoretically concerning the maximum function you can load into a lua state should be limited only by your ram (and i think youll have to sit quite a lot to write enough scripts to fill that up)

but on the other hand id guess it will be slower for every function cos the parser/interpreter has to search for the right function each time one is called

besides that it should be no problem (although im absolutely no expert with lua)


mfg Phreak
--
"Input... need input!" - Johnny Five, Short Circuit.
http://mitglied.lycos.de/lousyphreak/
Undoing a complete script (read more than one function call and so on...) is quite impossible.

If you only want to remove a parsed function or variable, simply set it to "nil". More difficult: get the global table and remove the unwanted entries (talking Lua 5.0)

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thanks!

So you must have unique names on all lua functions? You can''t have 2 funtions in diffrent script files that have the same name? That is not very good.

The only way I can think of, to use functions with same names, is to have a unique lua_State* for each file and manually copy all global funtions to this state, is that how it is supposed to work?
I''m not sure but i think in every scope you can have only one variable/function with the same name. You can however have functions with the same names in different tables (just like object member functions). Lua also does not allow function overloading (same name, different params).

When you let two scripts parse when both define a function with the same name, the second script will redefine the function.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

The "standard" method of dealing with it, is to put all of the functions into a table for that library. If you then want to remove the script, you can do it by removing the library''s table from the global table (setting it to nil). This will also prevent name conflicts, as the functions in one table will not be replaced by functions of the same name in a different table.

I suggest you read Lua Technical Note 7, at www.lua.org (to be specific: http://www.lua.org/notes/ltn007.html)

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
Thanks!

This topic is closed to new replies.

Advertisement