Jump to content

if exec load a script, how can unload?


Johxz

Recommended Posts

Thanks Jason sorry not to mention I know the packages. But I need to do more test with this.


@rlranft packages is for one function or few? I want to disable or unload a complete script. Or what is the best practice? use packages and put all the functions inside?


I have a few triggers and stuff made with scripts and only execute once, but the problem I see, a lot of them are in memory and will not will used anymore. Therefore I want to unload all the stuff I will not be used and of course load the new scripts.


thanks for your helps

Link to comment
Share on other sites

For an example of "many or few" look at scripts/server/game.cs and scripts/server/gameDM.cs - gameDM.cs overrides game.cs for DeathmatchGame, and it only overrides part of the base set of scripts.


As far as memory consumption - I can't imagine scripts using more than a few megabytes of RAM. To my knowledge this has never been an issue. Remember - when the game is executing, the scripts are all compiled to byte-code - much smaller than even the text script files.

Link to comment
Share on other sites

The question you also need to ask is whether packages actually free any memory when they're popped - as far as I'm aware, all they do is remove the functions from the namespace stack, so you can't access them. They still 'exist', I think.


As for your question on best-practises: one best practise is not to worry about tiny amounts of memory until you actually have a memory problem ;).

Link to comment
Share on other sites

If you are looking to remove unused objects (in this case triggers) that were added through a script, just surround them with a simgroup, and then delete that simgroup when you are done with it.


Then if you need the triggers back, just re-execute the .cs script that includes them.


We use this to add/remove deck objects from our Starship Enterprise. We have each deck's contents stored in a separate .cs file, and a trigger on each deck that is tagged with which objects to load. When you go to that deck it will execute the relevant script and load in all the objects for that deck. Then when you leave the deck (exit the trigger) it deletes the simgroups that it just loaded. When you go back to the deck, we re-execute the .cs. And so on...

Link to comment
Share on other sites

If you are looking to remove unused objects (in this case triggers) that were added through a script, just surround them with a simgroup, and then delete that simgroup when you are done with it.


Then if you need the triggers back, just re-execute the .cs script that includes them.


We use this to add/remove deck objects from our Starship Enterprise. We have each deck's contents stored in a separate .cs file, and a trigger on each deck that is tagged with which objects to load. When you go to that deck it will execute the relevant script and load in all the objects for that deck. Then when you leave the deck (exit the trigger) it deletes the simgroups that it just loaded. When you go back to the deck, we re-execute the .cs. And so on...

 

Thank very much Paul, may be this is what I need ;) delete or destroy and them if I need it, re-execute the .cs.

Link to comment
Share on other sites

Just to point it out, this is what happens between missions already - the players leave the mission, the mission group is deleted, then the next mission is loaded.

 

thanks @rlranft, I was trying to mimic basically the loading screen of half-life, I have a large level divide by zones, so went the player enter to a new zone I don't want the old stuff from the other zone still there.

Link to comment
Share on other sites

That's a good idea - another fellow was having a problem loading large numbers of objects in a single mission. He wasn't having memory or performance problems, his problem was that the simdictionary has (had?) a hard-coded limit to how many objects could have unique identifiers and it would reuse ids instead of refusing to load a new object. It was playing havoc with his scripts.

Link to comment
Share on other sites

Scripts cant be explicitly unloaded, but they are reference counted so if you are no longer using functions defined within a codeblock it should get destroyed. If you have no functions in your codeblock, even better - it should get destroyed as soon as you finish exec'ing it.


Strings and identifiers within scripts however aren't released since they get inserted into the StringTable, though this is usually not a problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...