Difference between revisions of "Legacy:RequireSystemScript"

From Spherical
Jump to: navigation, search
m (Notes: space)
(Examples: new convention)
 
Line 24: Line 24:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
In this example, <code>Delay(2000)</code> is a piece of code that is found in the [[Script:time.js|system script ''time.js'']], so when using it in this script it will look up the function in the system script time.js.
+
In this example, <code>Delay(2000)</code> is a piece of code that is found in the [[Script:System/time.js|system script ''time.js'']], so when using it in this script it will look up the function in the system script time.js.
  
 
<syntaxhighlight>
 
<syntaxhighlight>
Line 40: Line 40:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<code>Menu()</code> is an object that can be found in the [[Script:menu.js|system script ''menu.js'']]. All of its properties are taken over when creating a new Menu() somewhere.
+
<code>Menu()</code> is an object that can be found in the [[Script:System/menu.js|system script ''menu.js'']]. All of its properties are taken over when creating a new Menu() somewhere.
  
 
==Notes==
 
==Notes==

Latest revision as of 01:54, 2 June 2013

The RequireSystemScript(filename) command will do the same thing as the EvaluateSystemScript(filename) command, except it will only allow each system script to be loaded once. The purpose of this is the same as that of RequireScript, but works for system scripts instead (see EvaluateSystemScript).

Usage

RequireSystemScript(filename);


  • filename string. The name of the system script to be executed.

Examples

RequireSystemScript("time.js");

function game()
{
  var font = GetSystemFont();
  font.drawText(0,0, "This line is shown first");
  FlipScreen();
  Delay(2000);
  font.drawText(0,0, "Then this line is shown 2 seconds later.");
  FlipScreen();
  GetKey();
}

In this example, Delay(2000) is a piece of code that is found in the system script time.js, so when using it in this script it will look up the function in the system script time.js.

RequireSystemScript("menu.js");

function game()
{
  // This shows a basic menu
  var menu = new Menu();

  menu.addItem("Start New Game",    NewGame);
  menu.addItem("Exit",        Exit);
  menu.execute(250, 400, 140, 30); 
}

Menu() is an object that can be found in the system script menu.js. All of its properties are taken over when creating a new Menu() somewhere.

Notes

See EvaluateSystemScriptand RequireScript for more details.

See also