RiftWorks
Найти
Персональное меню
Вы не представились системе
user-interface-preferences
Персональные инструменты
Обсуждение
Вклад
Создать учётную запись
Войти
Параметры
notifications
Редактирование:
NT Script
(раздел)
associated-pages
Статья
Обсуждение
Просмотры
Читать
Править
Править код
История
Внимание:
Вы не вошли в систему. Ваш IP-адрес будет общедоступен, если вы запишете какие-либо изменения. Если вы
войдёте
или
создадите учётную запись
, её имя будет использоваться вместо IP-адреса, наряду с другими преимуществами.
Анти-спам проверка.
Не
заполняйте это!
== Syntax Guide == NT Script follows a simple-to-use syntax designed for users of all levels of programming expertise. Whitespace is ignored, semicolon break points are required, and curly brackets are required. === Variables === Variables are used to temporarily store any form of data that can be accessed somewhere else in the code. For simplicity, we'll ignore the fact that you can only use variables in children scope. Here is how you create a variable: $myVariable = 5; // The $ indicates that it is a variable. You can alternatively assign the same variable a text value, or a string. $myVariable = "Hello world!"; === Functions === Functions can be used and defined dynamically. There are different pre-defined functions for each NTSL implementation, however the basic ones will remain the same. Here is how you use a function: $myVariable = getNumber(); In this example, ''$myVariable'' is assigned whatever value getNumber() returns. Each function returns a value, even if a value return is explicitly not defined. Here are some more examples of how to use functions: broadcast($myVariable); broadcast("Hello world!"); broadcast("Griffing assistants in T-minus " + $myVariable + " seconds."); You can also define your own functions, using the ''def'' keyword. def getNumber() { return 5; } === 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". Here is a list of all relational operators: <br>'''==''' : Equals <br>'''!=''' : Does not equal <br>'''<''' : Less than <br>'''>''' : Greater than <br>'''<=''' : Less than or equal to <br>'''>=''' : Greater than or equal to 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 }
Описание изменений:
Обратите внимание, что все изменения в RiftWorks рассматриваются как выпущенные на условиях лицензии Creative Commons Attribution-NonCommercial-ShareAlike (см.
RiftWorks:Авторские права
). Если вы не хотите, чтобы ваши тексты свободно распространялись и редактировались любым желающим, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений или скопировали их из источника в общественном достоянии или под совместимой лицензией.
Не размещайте без разрешения материалы, защищённые авторским правом!
Отменить
Справка по редактированию
(в новом окне)