|
Math operations, Conditions and Anchors |
|
Written by eaxs
|
|
Thursday, 27 August 2009 00:58 |
Math operations Each math operation requires you to encapsule it in square brackes, like this:
You can use every common math operator like:
- + -- Add
- - -- Subtract
- * -- Multiply
- / -- Divide
- % -- Modulo
Comparison operations You can also compare numbers with relational operators. If you want to compare strings, use the StringEquals function instead!
- == -- equal to
- != --not equal to
- > -- greater than
- < -- less than
- >= -- greater than or equal
- <= -- less than or equal
Conditions To create a condition, we use the If command, like this:
If [3 > 1] "Echo This is true"
If #StringEquals(hello,hello)# "Echo This is true" Nesting conditions
If #StringEquals(hello,hello)# "If [3 > 1] Echo This is true" Anchors Savage 2 parses each script starting from left to right and from top to bottom, as it is usual. However, you can tell the parser to jump to a certain line in your script using anchors. You can move the pointer up and down, using the GoTo command:
GoTo SkipLine
Echo "This message will never appear because it gets skipped"
@SkipLine As you can see the message will never appear. We define an anchor in the script using the @ Symbol. Now you may ask what practical purpose an anchor has... For example you could create a loop like this:
CreateVar int _i 0
@Loop
Set _i [_i + 1]
Echo This message will appear 5 times
If [_i < 5] GoTo Loop Or you could execute only a part of your script if a condition is true (notice the "GoTo End"):
If [3 > 1] GoTo IsTrue
GoTo IsFalse
@IsTrue
Echo Its true
Goto End
@IsFalse
Echo Its false
@End
|