Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 2.25 KB

13.md

File metadata and controls

39 lines (24 loc) · 2.25 KB

LERN/LS/13

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.

Script.RunningTime

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

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

The wait command waits until at least a specified amount of time has passed.

This command accepts either

  1. one parameter as an integer number of deciseconds (tenths of a second, meaning 50 is 5 seconds), or
  2. an -s parameter (short for "seconds") followed by a float (decimal) number of seconds.

Wait precision

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.

Exercises

  1. Un-comment the waitframe line in atom tight, and try running the script

  2. Add another waitframe or two in function main

  3. Try changing the wait -s 2.04 to wait -s 0.001

  4. Limit the FPS to 10 by entering the command maxfps -fg 10, and then run the script again!