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 [2021/05/05 12:02] justinscript_syntax [2021/11/04 19:31] justin
Line 98: Line 98:
 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 $in range(0, $item_list.size()) do +$item_list = array["ITEM_0001", "ITEM_0002", "ITEM_0003"]; 
-   give_item($item_list[$i]);+for $item_id in $item_list do 
 +   give_item($item_id);
 end; end;
 </code> </code>
-Gives one of every item in $item_list to the player by iterating over the entire [[array]]. This assumes you have previously defined an $item_list variable that contains an [[array]] of [[string|string]] values for each item ID. The "size" function can be used in cases like this where you may not know how many elements the [[array]] contains.+Gives one of every item in $item_list to the player by iterating over the entire [[array]].
 <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"str($i), $i);
 end; end;
 </code> </code>
Line 111: Line 112:
  
 =====Data Types===== =====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/list of values. These values can be stored in variables or properties (see assignment statements above, or [[Set Global Property]] and [[Set Entity Property]]), and can be compared to another value of the same type using a [[conditional expression]].+There are several data types available in the scripting language used to represent a value or, in the case of an array or codex, a collection/list of values. These values can be stored in variables or properties (see assignment statements above, or [[Set Global Property]] and [[Set Entity Property]]), and can be compared to another value of the same type using a [[conditional expression]].
  
 ^Type^Examples^ ^Type^Examples^
Line 120: Line 121:
 |[[Color]]|color[255, 0, 255]| |[[Color]]|color[255, 0, 255]|
 |[[Entity]]|player, self, entity["sign"]| |[[Entity]]|player, self, entity["sign"]|
-|[[Array]]|group["room_01"], self.groups|+|[[Array]]|array["ITEM_0001", "ITEM_0002"], group["room_01"], self.groups
 +|[[Codex]]|
 |Null|null| |Null|null|
  
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin