Rules where to insert wait commands into script files?


(Ragnar_40k) #1

I noticed that there are severel wait commands inside the original script files. Are there any special rules where to place a wait command into a script file? E.g. after certain commands?


(sock) #2

The most important situation for a wait statement in the script is when you are trying to do something in a spawn function of an entity. When the map first starts, not all of the entities are ready for use and it is recommended that at least a wait of 50 is required if you are trying to access an entity on the map somewhere.

Sock
:moo:


(Doc) #3

Just to clarify, the wait on spawn is only necessary if the entity that is spawning accesses (eg. setstate, trigger) a different entity, true?


(chavo_one) #4

The wait on spawn is necessary if you want to do most anything with the entity inside it’s spawn function.

That would include gotomarker, faceangles, or really any command at all. If the game tries to reference the entity before it has spawned, you’ll have problems.


(digibob) #5

To clarify:

When using a script command that relies on an entity OTHER than the entity calling the command, you will need to ensure that entity has spawned. This usually comes from the spawn event as was mentioned. I would advise a slightly longer wait than the 50ms sock suggested, as some entities take longer to fully set themselves up, generally 200ms is enough for anything.


(Ragnar_40k) #6

What can happen when I obmit the wait command and the entity hasn’t spawned yet? Will it crash/lock up, ignore the command or just wait until the entity spawned? How can I find out, if my wait command lasts not long enough?


(chavo_one) #7

Your map will not load and you’ll get an error message. This is what was happening to Damocles:

http://www.splashdamage.com/forums/viewtopic.php?t=4216


(damocles) #8

Yay I’m famous! :smiley:


(chavo_one) #9

or is that infamous? :disgust: :smiley:


(digibob) #10

You’d likely get an error saying that the entity couldn’t be found and/or weird things will happen (usually the latter only happens when mucking up construction related stuff) despite your insistance that the entity exists :wink: