What does this command do?

The place to discuss scripting and game modifications for X²: The Threat.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

What does this command do?

Post by azaghal »

Could someone please answer me what does the following command in a script do and why should it be called inside of the setup.* scripts (and is it really needed)?

Code: Select all

@ = wait 6 ms
P.S.
Ok, I'm guessing it causes the script to wait for 6ms, but I just want to make sure ;)
User avatar
esd
Posts: 18002
Joined: Tue, 2. Sep 03, 05:57
x3tc

Post by esd »

It adds a delay to the script, making it wait for the set time. This has a side-effect of putting the script at the end of the queue to be run, which is very useful in a init script as it'll allow all other scripts to load and start running before it continues.
esd's Guides: X² Loops - X³ MORTs
azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

Post by azaghal »

Well, it seems that whenever this command is being executed during the init or setup phase, the game crashes in my case (if you've read some of my other posts, you'll know what I mean). So, is there any way to substitute this command with some form of for loop or something else which would be more efficient than the for loop? I ran the following test with X2 1.4.0.3 (no bonus scripts) in order to check if the game crashes only if the wait function is called in the main setup.* script, and it always crashes (no matter from within which script it is called during the init/setup phase).

executeme.xml:

Code: Select all

001 @ = wait 2000 ms
002   play sample: incoming transmission [PLAYERSHIP], from object Boron
003   return null
setup.test.xml:

Code: Select all

001 @ = [THIS] -> call script 'executeme' : 
002   return null
P.S.
This is a semi-technical problem question, since I want to see if there's a workaround for the wait function.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

it does slightly more than a delay, its adds an interupt point.

althou scripts appear to be multi threaded, running multiple scirpts at once, they infact arn't.

only 1 script can be run at a time, so they all stack up. Once the script reachs an interupt point, then next script on the stack can be run, then the previous script will continue after doing other scripts.



however, setup scripts are slightly different, they ignore interupt points so the next setup script wont run until the preivous completly finishes.

thats y u shouldn't really use delays in setup scripts, as it will block the rest of the scripts from running.

so a 6ms wait in a setup script is completly pointless
azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

Post by azaghal »

Thanks for such a thorough answer. Well, in any case, those are not my mods, but it's nice to know that removing those things won't harm them in any way (although I'll still need to check those scripts that are called within the init/setup scripts, some of them might be called later on during the game, although I doubt it). Thanks once again ;)

P.S.
All those great mods, here I come! :D

Return to “X²: The Threat - Scripts and Modding”