1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
Testing your scripts
====================
There are two main ways to test your scripts:
- using the [Open Surge](#using-open-surge) game engine;
- using the [SurgeScript standalone runtime](#using-the-standalone-version) (i.e., the version without a game engine).
Using Open Surge
----------------
To test a script in Open Surge, place it on the *scripts/* folder and start the engine. Your test script must include an object called *Application*. Make sure to remove the script after you're done with the testing.
As an example, save the following script to *scripts/hello.ss* and start the engine:
```
// hello.ss: test script
// Please remove this file after you're done
object "Application"
{
state "main"
{
Console.print("Hello, world!");
state = "done";
}
state "done"
{
}
}
```
You should see the *Hello, world!* message as a result.
**Linux users:** when using a system-wide installation, you may place your scripts on *~/.local/share/opensurge2d/opensurge/scripts/* (i.e., *$XDG_DATA_HOME/opensurge2d/opensurge/scripts/*).
Ready to proceed? Let's go to [Introduction to objects](/tutorials/objects)!
Using the standalone version
----------------------------
If you've downloaded the standalone version of the language:
- First of all, save the following script to a file named *hello.ss*. For testing purposes, you may place the file on the same directory as the surgescript executable.
```
// hello.ss: test script
object "Application"
{
state "main"
{
Console.print("Hello, world!");
Application.exit();
}
}
```
- Then, open up a Terminal and type:
```
cd /path/to/surgescript
./surgescript hello.ss
```
- If you're using Microsoft Windows, open up a Command Prompt and type:
```
cd C:\path\to\surgescript
surgescript.exe hello.ss
```
- You should see the output of the script as a result:
```
Hello, world!
```
To begin our learning adventure, let's go to [Introduction to objects](/tutorials/objects).
|