Schedulable scripts

From Hack/Mine Wiki
Revision as of 20:37, 10 June 2013 by Frizzil (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Schedulable scripts are Spellscript scripts that may be scheduled to run on the server at intervals dictated by their return values.

Creation

They may be created in several ways:

  • By use of the Spellscript IDE, brought up with 'tilde' by default. The user must be opped. When the IDE is exited, the script will be executed immediately.
  • By use of the 'schedule <uniqueID>' command. This must be either run from the console or as an op. If run from the console, line breaks may be added via "shift + return". Otherwise, line breaks may be specified by ending lines with backslashes before pressing enter. Otherwise, upon pressing enter, the script will be executed immediately.
  • In Spellscript, by use of the bool SERVER.scheduleScript(str uniqueID, int$() script, int delay) and bool SERVER.scheduleScriptLocal(str uniqueID, int$() script, int delay) methods. The given script will be executed after delay ticks have expired. The first variant does nothing if the machine is remote, otherwise executing the script locally and propagating it to any clients; the second variant only executes the script on the machine the calling script is being executed on, whether it's remote or non-remote.

Return Value

Each script is expected to return an int value:

  • Positive values indicate how many ticks to wait before re-executing the script.
  • Zero values indicate that the script should be immediately re-executed.
  • Negative values indicate that the script should be de-scheduled.
Carelessly returning zero in all cases will deadlock your server! Don't do that.

Management

Each script is associated with a unique identifier given by the user, by which it may later be referenced. Specifically, unschedule <script name> may be used to unschedule the script. All scheduled scripts may be listed by use of show-scripts.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox