This example consists of a single file, LS/13.iss
This example demonstrates waitframe
and wait
commands, which would produce errors in any atomic function.
Enter the command run lern/ls/13
to run the example.
Accessing the object called Script
provides data and actions that relate to the currently executing script, via a built-in script
object type. The script
type has a member called RunningTime
which returns the number of milliseconds since the script started.
This example shows ${Script.RunningTime}
in its output demonstrate the amount of time that has passed after waiting.
The waitframe
command waits until the game has prepared and is rendering a new frame. Hence the name of the command.
This command is only valid within a function
-- not within an atom
or method
or member
, all of which are atomic by definition. If waitframe
is used in atomic code, the script will end with an error.
The wait
command waits until at least a specified amount of time has passed.
This command accepts either
- one parameter as an integer number of deciseconds (tenths of a second, meaning 50 is 5 seconds), or
- an
-s
parameter (short for "s
econds") followed by a float (decimal) number of seconds.
The precision of wait
, regardless of whether specified in deciseconds or seconds, depends on the amount of time it takes for the host game (or application) to prepare the next frame for rendering, known as the framerate or frames per second (FPS).
If the game is running at 10 FPS, this means that it takes about 100ms for each frame. In that case, a waitframe
will last 100ms, and so will wait -s 0.001
.
That is to say, wait times will be effectively "quantized" to the framerate interval.
-
Un-comment the
waitframe
line inatom tight
, and try running the script -
Add another
waitframe
or two infunction main
-
Try changing the
wait -s 2.04
towait -s 0.001
-
Limit the FPS to 10 by entering the command
maxfps -fg 10
, and then run the script again!