Difference between revisions of "Legacy:EvaluateSystemScript"
From Spherical
(created from http://web.archive.org/web/20110804045041/http://www.spheredev.org/wiki/EvaluateSystemScript) |
(Cleanup) |
||
Line 1: | Line 1: | ||
− | + | The EvaluateSystemScript(filename) command will execute the [[system scripts|system script]] called "filename." All the possible system scripts available are located in the <var>/system/scripts</var> directory of the Sphere installation. | |
− | |||
− | The EvaluateSystemScript(filename) command will execute the system script called "filename." All the possible system scripts available are located in the /system/scripts directory of the Sphere installation. | ||
__TOC__ | __TOC__ | ||
==Usage== | ==Usage== | ||
− | {{Usage | + | {{Usage|func=EvaluateSystemScript|params=filename}} |
− | * ''' | + | * '''filename''' string. The name of the system script file to be run. |
− | |||
− | |||
==Examples== | ==Examples== | ||
− | ( | + | <syntaxhighlight> |
+ | EvaluateSystemScript("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(); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | <syntaxhighlight> | ||
+ | EvaluateSystemScript("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); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
==Notes== | ==Notes== | ||
− | + | There are many [[system scripts]] available, though the above two mentioned the most commonly used. The purpose of these scripts is to give inexperienced users of Sphere some common, easy to use commands to use in their games. As a user's experience with Sphere increases, they will tend to make their own versions of these to tailor to the specific needs of their game. Apart from that, system scripts provide general purpose library functions, that might be useful to everyone. | |
==See also== | ==See also== | ||
− | * | + | * [[API:EvaluateScript|EvaluateScript]](filename) |
− | * | + | * [[API:RequireScript|RequireScript]](filename) |
− | * | + | * [[API:RequireSystemScript|RequireSystemScript]](filename) |
− | * | + | * Category [[:Category:Scripts|Scripts]] |
Revision as of 00:59, 2 June 2013
The EvaluateSystemScript(filename) command will execute the system script called "filename." All the possible system scripts available are located in the /system/scripts directory of the Sphere installation.
Contents
Usage
EvaluateSystemScript(filename);
- filename string. The name of the system script file to be run.
Examples
EvaluateSystemScript("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();
}
EvaluateSystemScript("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);
}
Notes
There are many system scripts available, though the above two mentioned the most commonly used. The purpose of these scripts is to give inexperienced users of Sphere some common, easy to use commands to use in their games. As a user's experience with Sphere increases, they will tend to make their own versions of these to tailor to the specific needs of their game. Apart from that, system scripts provide general purpose library functions, that might be useful to everyone.
See also
- EvaluateScript(filename)
- RequireScript(filename)
- RequireSystemScript(filename)
- Category Scripts