User Tools

Site Tools


script_syntax

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
script_syntax [2017/10/16 07:19] justinscript_syntax [2020/01/19 18:30] justin
Line 2: Line 2:
 ---- ----
  
-The scripting language in RPG in a Box is a simple imperative language designed specifically for the engine. It is based on the language described [[http://jayconrod.com/posts/37/a-simple-interpreter-from-scratch-in-python-part-1|here]] in the series of articles by Jay Conrod. The syntax is useful to know for creating [[quick script|quick scripts]] for tiles and objects in the [[Map Editor]] or for script nodes in the [[Dialogue Editor]].+The scripting language in RPG in a Box is a simple imperative language designed specifically for the engine. It is loosely based on the language described [[https://jayconrod.com/posts/37/a-simple-interpreter-from-scratch-in-python-part-1|here]] in the series of articles by Jay Conrod. The syntax is useful to know for creating [[quick script|quick scripts]] for tiles and objects in the [[Map Editor]] or for script nodes in the [[Dialogue Editor]].
  
-=====Statements====== +=====Statement Syntax===== 
-Statements are the basic building blocks of the scripting language and represent a particular action to be taken. Currently, a statement can be either a function call or conditional "if/then/else/end" statement. Multiple statements must be separated from each other using semicolons (;).+Statements are the basic building blocks of the scripting language and represent a particular action to be taken. statement can be either a function call, assignment of value to a variable/property, or control statement (i.e. "If" statement, "While" loop, or "For" loop). Multiple statements must be separated from each other using semicolons (;). Whitespace between statements is ignored, although newlines and indentation are recommended for ease of reading.
  
-====Function Calls====+=====Function Calls=====
 Calling a function instructs the game to execute some piece of logic, for example to display a message to the player or to move the camera to a specific location. See [[Scripting Reference]] for a comprehensive list of built-in functions that can be called. Calling a function instructs the game to execute some piece of logic, for example to display a message to the player or to move the camera to a specific location. See [[Scripting Reference]] for a comprehensive list of built-in functions that can be called.
  
Line 20: Line 20:
 </code> </code>
  
-====If/Then/Else/End (Conditional)==== +=====Control Statements===== 
-The "if/then/else/endsyntax allow you to branch your logic according to the results of a condition being evaluated. In the order listed, it consists of the keyword "if", a condition to check, the "then" keyword, any statements to execute if the condition is true, optionally the "else" keyword followed by any statements to execute if the condition is not true, and lastly the "end" keyword. See [[Conditional Expression]] for more information and a list of valid comparison operators that can be used in the condition.+Control statements affect the flow of your script, either by branching or looping through a set of statements multiple times. These include "Ifstatements, "While" loops, and "For" loops. 
 + 
 +====If Statement==== 
 +**If statements** allow you to branch your logic according to the results of a condition being evaluated. In the order listed, it consists of the keyword "if", a condition to check, the "then" keyword, any statements to execute if the condition is true, optionally the "else" keyword followed by any statements to execute if the condition is not true, and lastly the "end" keyword. See [[Conditional Expression]] for more information and a list of valid comparison operators that can be used in the condition.
  
 **Examples:** **Examples:**
Line 30: Line 33:
 </code> </code>
 <code lua> <code lua>
-if player.inventory contains "Gold Key" then+if player.inventory contains "ITEM_0001" then
    remove_item("Gold Key");    remove_item("Gold Key");
    display_message("The door is now unlocked!");    display_message("The door is now unlocked!");
Line 38: Line 41:
 end end
 </code> </code>
 +
 +====While Loop====
 +**While loops**
 +
 +====For Loop====
 +**For loops**
  
 =====Literals===== =====Literals=====
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin