Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Excerpt

Queue a call to a function until a later frame.

 

Purpose

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

The function, when called, will be run in the context of the global scope ("this" will be the global scope). So, if you've added properties or methods to the function, they won't be available from within the function when it's run as a result of being queued.

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

Code Block
themeRDark
languagejavascript
linenumberstrue
queue(functionName,delay,gameObject);

Parameters

ParameterTypeMandatoryDescription
functionNameString(tick)

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.

delayNumber(error)

You can optionally set a minimum amount of time (in milliseconds) before your function gets called. Delays should ideally be 500 or more, and never less than 100.

If you don't specify this parameter, or specify 0 (zero), Warzone will choose a delay for you.

gameObjectGame object(error)

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

ValueTypeDescription
undefinedUndefinedThe function was successfully queued.
<error>ErrorDid you forget to specify functionName as a string? Duh!

Example

Code Block
themeRDark
languagejavascript
titleCall function "foo" every second
linenumberstrue
function foo(gameObj) {
  // do stuff
}

queue("foo",0,someGameObject); // at a later frame, global["foo"](someGameObject) will be called.
Div
classbox

Contents

Assimilate:

Table of Contents
excludeContents

Div
classbox

See also

Related functions:

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