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
script_syntax [2022/05/17 22:13] justinscript_syntax [2023/11/06 14:13] (current) justin
Line 2: Line 2:
 ---- ----
  
-**Bauxite**, the scripting language for RPG in a Box, is a simple imperative language designed specifically for the engine. The syntax for Bauxite 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]].+**Bauxite**, the scripting language for RPG in a Box, is designed specifically for the engine. The syntax for Bauxite 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]].
  
 =====Statement Syntax===== =====Statement Syntax=====
Line 116: Line 116:
 ^Type^Examples^ ^Type^Examples^
 |[[String]]|"Hello, world!", "This is a string."| |[[String]]|"Hello, world!", "This is a string."|
-|[[Decimal]]|17, 3.14159|+|[[Number]]|17, 3.14159|
 |[[Boolean]]|true, false| |[[Boolean]]|true, false|
 |[[Coordinate]]|coord[1, 2, 3], entity["slime_01"].coord| |[[Coordinate]]|coord[1, 2, 3], entity["slime_01"].coord|
Line 158: Line 158:
  
 ====Codex==== ====Codex====
-A codex is a data type with its data stored as key/value pairs. The key is a unique [[string]] and acts as a lookup for its corresponding value within the codex, similar to a dictionary. See [[Codex]] for more information and some scripting examples.+[[codex]] is a data type with its data stored as key/value pairs. The key is a unique [[string]] and acts as a lookup for its corresponding value within the codex, similar to a dictionary. See [[Codex]] for more information and some scripting examples.
  
 ====Null==== ====Null====
Line 206: Line 206:
 </code> </code>
 Gives either ITEM_0001 or ITEM_0002 to the player, with a 25% chance that the item will be ITEM_0001. Gives either ITEM_0001 or ITEM_0002 to the player, with a 25% chance that the item will be ITEM_0001.
 +
 +====Dice Rolls====
 +Bauxite also supports a dice notation similar to that of Dungeons & Dragons for generating random numbers. Specifically, **XdY**, where **X** is the number of dice to roll and **Y** is how many sides the dice have.
 +
 +**Examples:**
 +<code bauxite>
 +$result = 1d20;
 +</code>
 +Gives the result of rolling a twenty-sided die.
 +
 +<code bauxite>
 +$result = 2d8 + 1d6;
 +</code>
 +Gives the result of rolling two eight-sided dice and one six-sided die.
  
 ====Range==== ====Range====
Line 230: Line 244:
 </code> </code>
 List of integers from 5 to, but not including, 0, with an increment of -1 (i.e. 5, 4, 3, 2, 1). List of integers from 5 to, but not including, 0, with an increment of -1 (i.e. 5, 4, 3, 2, 1).
 +
 +====Duplicate====
 +The **duplicate** function creates a unique copy of an [[array]] or [[codex]]. Since the copy is unique, you can modify its data without affecting the original [[array]] or [[codex]].
 +
 +With the code below where the value in **$items** is simply stored into another variable, in this case **$items_copy**, the new variable or property will only contain a reference to the original [[codex]], so any changes to one will affect the other (i.e. both "print" statements will display 10).
 +<code bauxite>
 +$items = codex["id": "ITEM_0001", "count": 5];
 +$items_copy = $items;
 +$items_copy["count"] = 10;
 +print($items["count"]);
 +print($items_copy["count"]);
 +</code>
 +
 +In the example below, a copy of **$items** is made using the "Duplicate" function. Since it's now a unique copy of the [[codex]], if the "count" key is changed to 10 for the **$items_copy** variable, the original **$items** [[codex]] will remain unchanged. Therefore, the first "print" statement will display 5, while the second "print" statement will display 10.
 +<code bauxite>
 +$items = codex["id": "ITEM_0001", "count": 5];
 +$items_copy = duplicate($items);
 +$items_copy["count"] = 10;
 +print($items["count"]);
 +print($items_copy["count"]);
 +</code>
  
 ====Inverse==== ====Inverse====
script_syntax.1652850802.txt.gz · Last modified: 2022/05/17 22:13 by justin