Строка 1: |
Строка 1: |
| + | {{Заготовка|url="http://www.ss13.eu/wiki/index.php/NTSL"}} |
| == Расшифровка == | | == Расшифровка == |
| NanoTrasen Scripting Language | | NanoTrasen Scripting Language |
Строка 50: |
Строка 51: |
| } | | } |
| | | |
| + | === Code Blocks === |
| + | |
| + | Blocks of code are called when a specific piece of code signals that it is a representation of a block of code. Variables defined in one code block cannot be applied or changed in other nonrelated code blocks; this is known as scope. For example: |
| + | |
| + | $myGlobalVariable = getNumber(); |
| + | |
| + | while($myGlobalVariable != 0) { |
| + | |
| + | $myLocalVariable = 0; |
| + | $myGlobalVariable = $myLocalVariable; |
| + | } |
| + | |
| + | $myLocalVariable = 50; // this is invalid; myLocalVariable does not exist in this scope |
| + | |
| + | Once the interpreter reads the closing bracket, it destroys all variable definitions within the scope, therefore you cannot use any of the variables that existed in that particular block of code. |
| + | |
| + | |
| + | === Conditionals === |
| + | |
| + | The while() loop in the previous example is considered a conditional because it only continues executing when the condition between the parentheses is true. The ''!='' is known as a relational operator which returns true to the interpreter if myGlobalVariable does not equal 0. It can be read as "while myGlobalVariable does not equal 0, execute the following block of code". |
| + | |
| + | Список операторов сравнения: |
| + | |
| + | *'''==''' : Равно |
| + | *'''!=''' : Не равно |
| + | *'''<''' : Меньше чем |
| + | *'''>''' : Больше чем |
| + | *'''<=''' : Меньше чем или равно |
| + | *'''>=''' : Больше чем или равно |
| + | |
| + | |
| + | Relational operators can be used in if(), and elseif(), statements, which are used the following way: |
| + | |
| + | if($myVariableNumber == 50) // if my number is 50 |
| + | { |
| + | // code block |
| + | } |
| + | elseif($myVariableNumber <= 30) // if not, is my number 30 or less? |
| + | { |
| + | // code block |
| + | } |
| + | else // if not either 50 OR 30 or more, do this instead |
| + | { |
| + | // code block |
| + | } |
| | | |
| == Синтаксические особенности == | | == Синтаксические особенности == |