Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Overview

Queue a call to a function until a later frame.

Unlike setTimer(), queue() does not repeat. It will make a single call to the named function at a later frame in the game.

Queued functions persist the save/load cycle. You can therefore look at Saved game files to see what queued functions were defined at the time the game was saved.

Syntax

queue(functionName,gameObject);

Parameters

ParameterMandatoryTypeDescription
functionName(tick)String

A string containing the name of the function to call.

The function must be defined on the global scope - it cannot be a method of an object or anything like that.

If you pass in a function, or the name of a function not on the global scope, an exception will be thrown.

gameObject(error)Game object

An optional game object that will be passed in to your function when it gets called. The object will automatically be refreshed with the latest game data.

If the object gets destroyed, the associated queued call will be cancelled automatically.

Return value

It's not clear what the return value will be, so ignore it.

Example

Call function "foo" every second
function foo(gameObj) {
  // do stuff
}

queue("foo",someGameObject); // after a short delay, global["foo"](someGameObject) will be called.

See also

  • setTimer() – similar to queue, but will repeatedly call the function at a defined interval
  • removeTimer() – cancels all timers associated with a function
  • No labels