This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
script_syntax [2017/10/13 11:16] – justin | script_syntax [2020/01/20 19:23] – justin | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- | ---- | ||
- | The scripting language in RPG in a Box is a simple imperative language designed specifically for the engine. | + | The scripting language in RPG in a Box is a simple imperative language designed specifically for the engine. |
- | =====Statements====== | + | =====Statement Syntax===== |
- | Statements are the basic building blocks of the scripting language and represent a particular action to be taken. | + | Statements are the basic building blocks of the scripting language and represent a particular action to be taken. |
- | ====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: | ||
</ | </ | ||
- | ====If/ | + | =====Assignment Statements===== |
- | The " | + | Assignment statements |
+ | |||
+ | ^Operator^Description^ | ||
+ | |=|Places the value on the right-hand side into the variable on the left-hand side.| | ||
+ | |+=|Adds the value on the right-hand side to the current value of the variable on the left-hand side, then places | ||
+ | |-=|Subtracts the value on the right-hand side from the current value of the variable on the left-hand side, then places the resulting value back into the variable.| | ||
+ | |*=|Multiplies the value on the right-hand side by the current value of the variable on the left-hand side, then places | ||
+ | |/=|Divides the value on the right-hand side by the current value of the variable on the left-hand side, then places the resulting value back into the variable.| | ||
**Examples: | **Examples: | ||
+ | <code freebasic> | ||
+ | rand_num = random(1, 20) | ||
+ | </ | ||
<code lua> | <code lua> | ||
- | if global.property[" | + | entity[" |
- | | + | </ |
+ | <code lua> | ||
+ | player.stat[" | ||
+ | </ | ||
+ | |||
+ | =====Control Statements===== | ||
+ | Control statements affect the flow of your script, either by branching or looping through a set of statements multiple times. These include " | ||
+ | |||
+ | ====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 " | ||
+ | |||
+ | **Examples: | ||
+ | <code lua> | ||
+ | if global.property[" | ||
+ | | ||
end | end | ||
</ | </ | ||
<code lua> | <code lua> | ||
- | if player.inventory contains "Gold Key" then | + | if player.inventory contains "ITEM_0001" then |
- | | + | |
| | ||
| | ||
Line 39: | Line 63: | ||
</ | </ | ||
- | =====Literals===== | + | ====While Loop==== |
- | A literal represents | + | While loops allow you to execute a set of statements repeatedly as long as a particular condition evaluates to true. In the order listed, it consists of the keyword " |
+ | |||
+ | **Example: | ||
+ | <code lua> | ||
+ | display_message(" | ||
+ | global.property[" | ||
+ | while global.property[" | ||
+ | | ||
+ | wait(2) | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | ====For Loop==== | ||
+ | For loops allow you execute a set of statements a given number of times based on an iterable expression (e.g. an [[array]] of values). In the order listed, it consists of the keyword " | ||
+ | |||
+ | **Example: | ||
+ | <code freebasic> | ||
+ | display_message(" | ||
+ | for slime_entity in group[" | ||
+ | | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | =====Data Types===== | ||
+ | There are several data types available in the scripting language used to represent a value or, in the case of arrays, a collection/ | ||
^Type^Examples^ | ^Type^Examples^ | ||
Line 46: | Line 94: | ||
|[[Decimal]]|17, | |[[Decimal]]|17, | ||
|[[Boolean]]|true, | |[[Boolean]]|true, | ||
+ | |[[Coordinate]]|coord[1, | ||
+ | |[[Color]]|color[255, | ||
+ | |[[Entity]]|player, | ||
~~NOTOC~~ | ~~NOTOC~~ |