User Tools

Site Tools


script_syntax

Script Syntax


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 here in the series of articles by Jay Conrod. The syntax is useful to know for creating quick scripts for tiles and objects in the Map Editor or for script nodes in the Dialogue Editor.

Statements

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 a conditional “if/then/else/end” statement. 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

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.

Examples:

display_message("Hello World!")
lock_camera();
move_camera("cam_position_01");
start_dialogue("cutscene_01")

If/Then/Else/End (Conditional)

The “if/then/else/end” syntax 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:

if global.property["gem_count"] > 5 then
   display_message("You've collected more than 5 gems!")
end
if player.inventory contains "Gold Key" then
   remove_item("Gold Key");
   display_message("The door is now unlocked!");
   set_entity_property(self, "locked", false)
else
   display_message("You need a gold key to unlock this door.")
end

Literals

A literal represents an explicit, fixed value. Literals can be stored in properties (see Set Global Property and Set Entity Property) or compared to another value of the same type within a conditional expression.

TypeExamples
String“Hello World!”, “This is a string.”
Decimal17, 3.14159
Booleantrue, false
script_syntax.txt · Last modified: 2019/04/18 16:03 (external edit)