@ <RetVar/IF> wait <Var/Number> ms

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Locked
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

@ <RetVar/IF> wait <Var/Number> ms

Post by mark_a_condren » Tue, 7. Sep 10, 14:50

@ [skip|else] if [not]|while [not]| <RetVar/IF> = wait <Var/Number> ms


[skip|else] if [not]|while [not]|= The possible 'Conditional' statements that can be used with this command.
<RetVar/IF> = The time remaining of the wait time entered.
<Var/Number> = The length of time to for the script to wait in milliseconds.


Causes the script to pause for the length of time specified by <Var/Number>.
The delay is approximate.
Generally it can be counted on that the delay will be at least for the specified length of time.
No delay can be less than the length of time it takes for one screen refresh, see Note, so a one millisecond wait will delay until the next refresh.

The game engine will give back the hand if it has nothing better to do if you give the wait <RetVar/IF> a large value. In this case the <RetVar/IF> is supposed to be the time left to wait (an approximation I guess) to reach the value you've supplied as an argument.


Example:
  • $Loop = 0
    while $Loop < 10
    @ = wait 200 ms
    | inc $Loop =
    end


This will create a 200 millisecond wait in each iteration of the 'while' statement.

To obtain the '=' without having 'null' there you select 'No return variable' from the list of possible conditional statements at the bottom of the SE menu.

----------------------------------

$ret = wait 10000 ms

If it gives back the hand after 6 secs, then $ret should then be equal to 4000.

----------------------------------

Caution Notes:

It's difficult to find any practical use to the IF / while statements here (the first one is unreliable, the other one has a fairly good chance to make an infinite loop).

if wait 1000 ms
| wait again ?
end

An additional note: long wait times (over a few seconds) are unreliable and should be cut in smaller ones when precision is necessary.

----------------------------------

Note:
Take the current refresh rate in frames per second and divide that into 1000 to get the number of milliseconds per frame.
This will be the minimum wait time.
A utility called 'fraps' (http://www.fraps.com) can tell you what your current frame rate is.
Of course, the frame rate in any given situation will depend on the processing power of the user's computer who is running your script.
But it's a good thing to remember that any wait placed in your script will delay for at least one frame.
For example, any wait placed inside a loop will cause the loop to iterate at most once per frame.


Command Location:
Last edited by mark_a_condren on Wed, 8. Sep 10, 14:01, edited 3 times in total.

Locked

Return to “MSCI Reference”