if exec load a script, how can unload?

There are no stupid questions, just stupid answers.
  • 1
  • 2
13 posts Page 1 of 2
Johxz
Posts: 447
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Tue Apr 28, 2015 11:55 pm
Hi... sorry :oops: I have other question...

how can unload a script? in the documentation not see nothing... I don't want some functions still there in the level. Exist something like unexec? :lol:

thanks!
Jason Campbell
Posts: 335
Joined: Fri Feb 13, 2015 2:51 am
 
by Jason Campbell » Wed Apr 29, 2015 1:27 am
I've never used them but functions can be placed in packages which can be activated or deactivated. Simobject methods can be packaged also.
rlranft
Posts: 308
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Apr 29, 2015 3:30 am
Yeah, packages are the best thing you can do - perhaps use them on a per-mission basis or something - but you can't actually unload a script.

The real question is, why? What are you trying to accomplish?
Johxz
Posts: 447
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Wed Apr 29, 2015 4:24 am
Thanks Jason sorry not to mention I know the packages. But I need to do more test with this.

@
User avatar
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
rlranft
Posts: 308
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Apr 29, 2015 6:52 am
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.
buckmaster
Steering Committee
Steering Committee
Posts: 321
Joined: Thu Feb 05, 2015 1:02 am
by buckmaster » Wed Apr 29, 2015 10:31 am
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 ;).
rlranft
Posts: 308
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Apr 29, 2015 4:21 pm
"Premature optimization is the root of all evil."
PaulWeston
Posts: 143
Joined: Thu Apr 23, 2015 7:16 pm
by PaulWeston » Thu Apr 30, 2015 5:33 pm
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...
Johxz
Posts: 447
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Thu Apr 30, 2015 5:59 pm
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.
rlranft
Posts: 308
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Thu Apr 30, 2015 10:51 pm
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.
  • 1
  • 2
13 posts Page 1 of 2

Who is online

Users browsing this forum: No registered users and 3 guests