scripting:basic_syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
scripting:basic_syntax [2020/01/28 18:57] – [Conditional Statements] 51.148.136.100 | scripting:basic_syntax [2023/05/15 02:08] (current) – [Arrays] mit | ||
---|---|---|---|
Line 34: | Line 34: | ||
===== Loops ===== | ===== Loops ===== | ||
'' | '' | ||
- | <codedoc> | + | <code> |
$loop = 0 | $loop = 0 | ||
while ( $loop < 10 ) | while ( $loop < 10 ) | ||
Line 41: | Line 41: | ||
$loop += 1 | $loop += 1 | ||
} | } | ||
- | </codedoc> | + | </code> |
===== Comments ===== | ===== Comments ===== | ||
Code comments are simple C-stylee, e.g | Code comments are simple C-stylee, e.g | ||
- | <codedoc> | + | <code> |
// Check the item number | // Check the item number | ||
if ( $itemNum = 112 ) | if ( $itemNum = 112 ) | ||
Line 52: | Line 52: | ||
// *say Nothing (this line is commented out) | // *say Nothing (this line is commented out) | ||
} | } | ||
- | </codedoc> | + | </code> |
===== Maths operators ===== | ===== Maths operators ===== | ||
- | Basic maths operators are supported in simple form. Compound operations are not yet supported so each line needs to be kept basic, e.g. : | + | Basic maths operators are supported in simple form. Compound operations are not yet supported so each line needs to be kept to a single operation, e.g. : |
- | <codedoc> | + | <code> |
$var = 1 | $var = 1 | ||
| | ||
$var += 1 | $var += 1 | ||
- | </codedoc> | + | </code> |
Currently the 4 basic operators ( '' | Currently the 4 basic operators ( '' | ||
Line 73: | Line 73: | ||
Example Local variable use : | Example Local variable use : | ||
- | <codedoc> | + | <code> |
Event( " | Event( " | ||
{ | { | ||
Line 82: | Line 82: | ||
} | } | ||
} | } | ||
- | </codedoc> | + | </code> |
Example module variable use : | Example module variable use : | ||
- | <codedoc> | + | <code> |
$mNumberOfBongoPlays = 0 | $mNumberOfBongoPlays = 0 | ||
Event( " | Event( " | ||
Line 91: | Line 91: | ||
*say $mNumberOfBongoPlays people have played the bongos since the script was last restarted | *say $mNumberOfBongoPlays people have played the bongos since the script was last restarted | ||
} | } | ||
- | </codedoc> | + | </code> |
Example global variable use : | Example global variable use : | ||
- | <codedoc> | + | <code> |
global $kNumberOfBongoPlays = 0 | global $kNumberOfBongoPlays = 0 | ||
Event( " | Event( " | ||
Line 100: | Line 100: | ||
*say $kNumberOfBongoPlays people have played the bongos since the script was last restarted | *say $kNumberOfBongoPlays people have played the bongos since the script was last restarted | ||
} | } | ||
- | </codedoc> | + | </code> |
===== Arrays ===== | ===== Arrays ===== | ||
Line 108: | Line 108: | ||
Arrays are declared and referenced as shown : | Arrays are declared and referenced as shown : | ||
- | <codedoc> | + | <code> |
$maTestArray[] = | $maTestArray[] = | ||
{ | { | ||
Line 120: | Line 120: | ||
*say The second text item in the array is $maTestArray[4] | *say The second text item in the array is $maTestArray[4] | ||
} | } | ||
- | </codedoc> | + | </code> |
.. which would print 'The first value in the array is 100' followed by 'The second text item in the array is Item 2'. | .. which would print 'The first value in the array is 100' followed by 'The second text item in the array is Item 2'. | ||
- | >> | + | * [[Scripting: |
scripting/basic_syntax.1580259474.txt.gz · Last modified: 2020/01/28 18:57 by 51.148.136.100