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 [2020/02/18 17:37] justinscript_syntax [2020/08/05 21:36] justin
Line 2: Line 2:
 ---- ----
  
-The scripting language in RPG in a Box is a simple imperative language designed specifically for the engine. 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]].+Bauxite, the scripting language for RPG in a Boxis 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]].
  
 =====Statement Syntax===== =====Statement Syntax=====
Line 12: Line 12:
 **Examples:** **Examples:**
 <code bauxite> <code bauxite>
-display_message("Hello World!")+display_message("Hello, world!")
 </code> </code>
 <code bauxite> <code bauxite>
Line 32: Line 32:
 **Examples:** **Examples:**
 <code bauxite> <code bauxite>
-rand_num = random(1, 20)+$rand_num = random(1, 20)
 </code> </code>
 <code bauxite> <code bauxite>
Line 63: Line 63:
 </code> </code>
 <code bauxite> <code bauxite>
-rand_num = random(1, 20); +$rand_num = random(1, 20); 
-if rand_num > 15 then+if $rand_num > 15 then
    give_item("ITEM_0001")    give_item("ITEM_0001")
-elseif rand_num > 10 then+elseif $rand_num > 10 then
    give_item("ITEM_0002")    give_item("ITEM_0002")
 else else
Line 92: Line 92:
 <code bauxite> <code bauxite>
 display_message("The explosion damages all of the enemies!"); display_message("The explosion damages all of the enemies!");
-for slime_entity in group["slimes"] do +for $slime_entity in group["slimes"] do 
-   damage_entity(slime_entity, 5)+   damage_entity($slime_entity, 5)
 end end
 </code> </code>
 Deals 5 damage to each [[entity]] in the "slimes" [[groups|group]]. Deals 5 damage to each [[entity]] in the "slimes" [[groups|group]].
 <code bauxite> <code bauxite>
-for i in range(1, 4) do +for $i in range(1, 4) do 
-   give_item("ITEM_000" + "${i}", i)+   give_item("ITEM_000" + "${i}", $i)
 end end
 </code> </code>
Line 108: Line 108:
  
 ^Type^Examples^ ^Type^Examples^
-|[[String]]|"Hello World!", "This is a string."|+|[[String]]|"Hello, world!", "This is a string."|
 |[[Decimal]]|17, 3.14159| |[[Decimal]]|17, 3.14159|
 |[[Boolean]]|true, false| |[[Boolean]]|true, false|
Line 118: Line 118:
  
 ====Arrays==== ====Arrays====
-An array is simply a list of values, such as the [[entity|entities]] belonging to a [[groups|group]], the tags assigned to a model, or even a custom set of values defined directly within a [[script]]. Refer to the [[Array]] documentation for more examples.+An [[array]] is simply a list of values, such as the [[entity|entities]] belonging to a [[groups|group]], the tags assigned to a model, or even a custom set of values defined directly within a [[script]]. Refer to the [[Array]] documentation for more examples.
 ^Type^Description^Example^ ^Type^Description^Example^
 |User-Defined|List of custom values declared with the "array" syntax.|array["A", "B", "C"]| |User-Defined|List of custom values declared with the "array" syntax.|array["A", "B", "C"]|
Line 126: Line 126:
 |Tags for an Entity|List of tags assigned to an [[entity|entity's]] model (see [[Model Properties]]).|player.tags, initiator.tags| |Tags for an Entity|List of tags assigned to an [[entity|entity's]] model (see [[Model Properties]]).|player.tags, initiator.tags|
  
-The values in an array can be iterated through using a "For" loop, or you can get the value at a specific position within the array using the index syntax //my_array[x]//, where "my_array" is an [[array]] variable and "x" is an integer ranging from 0 to one less than the [[array]] size. See below for some example script usages.+The values in an [[array]] can be iterated through using a "For" loop, or you can get the value at a specific position within the [[array]] using the index syntax //my_array[x]//, where "my_array" is an [[array]] variable and "x" is an integer ranging from 0 to one less than the [[array]] size. See below for some example [[script]] usages.
  
 **Examples:** **Examples:**
 <code bauxite> <code bauxite>
-for slime_entity in group["slimes"] do +for $slime_entity in group["slimes"] do 
-   damage_entity(slime_entity, 2)+   damage_entity($slime_entity, 2)
 end end
 </code> </code>
Line 142: Line 142:
 Displays the message if the player model's tag list contains the "human" tag. Displays the message if the player model's tag list contains the "human" tag.
 <code bauxite> <code bauxite>
-dungeon_map_list = array["room1", "room2", "room3", "room4"]; +$dungeon_map_list = array["room1", "room2", "room3", "room4"]; 
-load_map(dungeon_map_list[random(0, 3)], coord[0, 0, 0]); +load_map($dungeon_map_list[random(0, 3)], coord[0, 0, 0]); 
-item_list = array["ITEM_0001", "ITEM_0005", "ITEM_0008"]; +$item_list = array["ITEM_0001", "ITEM_0005", "ITEM_0008"]; 
-give_item(item_list[random(0, 2)], 5)+give_item($item_list[random(0, 2)], 5)
 </code> </code>
 Loads a random map from the "dungeon_map_list" array variable ("room1" through "room4"), then gives the player 5 of a random item from the "item_list" array variable. Loads a random map from the "dungeon_map_list" array variable ("room1" through "room4"), then gives the player 5 of a random item from the "item_list" array variable.
Line 165: Line 165:
 <code bauxite> <code bauxite>
 set_player_movement_locked(true); set_player_movement_locked(true);
-target_tile = tile[7, 8, 0]; +$target_tile = tile[7, 8, 0]; 
-if target_tile == null then+if $target_tile == null then
    print("Target tile doesn't exist.")    print("Target tile doesn't exist.")
 else else
-   move_player(target_tile)+   move_player($target_tile)
 end end
 </code> </code>
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin