Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Unity - Unload lua scripts or just load the new ones?

Author
Message
SirLeon
17
Years of Service
User Offline
Joined: 6th Jan 2007
Location: Greece
Posted: 19th Apr 2007 19:30
Hello,

Although I think I got it right it's best to ask about this.

As in the documentation of the Unity plugin there isn't a command to unload a previously loaded lua script I assume that when you load a new lua script that has for example a function with the same declaration as with a previsously loaded one, if you call this function you will get the latest version of it. Is this understanding correct?

I ask this because I tend to use lua scripting for level loading so there will be many times that I will load new but similar scripts during the execution of my application.

Thank you,
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 25th Apr 2007 18:21
you're right, I have also noticed this with Unity... no unload commands ...

It's something that must be added in next update of the product !!!

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
seaduck
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 1st May 2007 12:08
In LUA you can free a function or table by assigning nil to its name.

So... in LUA if functionname, tablename, and anyvariablename are defined as a function, table and variable, then doing the following in LUA:

functionname=nil
tablename=nil
anyvariablename=nil

...will free the function, table, and variable respectively.

Then, in LUA again, call collectgarbage() and memory should get cleaned up nicely.

Do this to all of your LUA variables and functions and then call (in LUA) collectgarbage() and you get a similar effect to having unloaded your LUA script.
seaduck
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 1st May 2007 12:52
I just noticed the LUA RESET command on page 35 of unity Manual.pdf. This might be more of what you are looking for as it resets Unity's LUA state completely.

Login to post a reply

Server time is: 2024-05-20 17:24:19
Your offset time is: 2024-05-20 17:24:19