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 [2020/02/06 19:45] – justin | script_syntax [2020/02/16 21:22] – justin | ||
---|---|---|---|
Line 87: | Line 87: | ||
====For Loop==== | ====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 " | + | 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:** | + | **Examples:** |
<code bauxite> | <code bauxite> | ||
display_message(" | display_message(" | ||
Line 96: | Line 96: | ||
end | end | ||
</ | </ | ||
+ | Deals 5 damage to each [[entity]] in the " | ||
+ | <code bauxite> | ||
+ | for i in range(1, 4) do | ||
+ | | ||
+ | end | ||
+ | </ | ||
+ | Gives the following items to the player: one of ITEM_0001, two of ITEM_0002, and three of ITEM_0003. | ||
=====Data Types===== | =====Data Types===== | ||
Line 108: | Line 115: | ||
|[[Entity]]|player, | |[[Entity]]|player, | ||
|[[Array]]|group[" | |[[Array]]|group[" | ||
+ | |Null|null| | ||
====Arrays==== | ====Arrays==== | ||
- | An array is simply a list of values, such as the [[entity|entities]] belonging to a [[groups|group]], | + | An array is simply a list of values, such as the [[entity|entities]] belonging to a [[groups|group]], |
^Type^Description^Example^ | ^Type^Description^Example^ | ||
|Entities in a Group|List of all [[entity|entities]] assigned to a map [[groups|group]].|group[" | |Entities in a Group|List of all [[entity|entities]] assigned to a map [[groups|group]].|group[" | ||
Line 139: | Line 147: | ||
</ | </ | ||
Loads a random map from the " | Loads a random map from the " | ||
+ | |||
+ | ====Null==== | ||
+ | The " | ||
+ | |||
+ | **Examples: | ||
+ | <code bauxite> | ||
+ | if x == null then | ||
+ | | ||
+ | end | ||
+ | </ | ||
+ | <code bauxite> | ||
+ | if entity[" | ||
+ | | ||
+ | end | ||
+ | </ | ||
+ | <code bauxite> | ||
+ | set_player_movement_locked(true); | ||
+ | target_tile = tile[7, 8, 0]; | ||
+ | if target_tile == null then | ||
+ | | ||
+ | else | ||
+ | | ||
+ | end | ||
+ | </ | ||
=====Functions===== | =====Functions===== | ||
Line 162: | Line 194: | ||
</ | </ | ||
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. | ||
+ | |||
+ | ====Range==== | ||
+ | The **range** function generates an [[array]] of integers based on the supplied parameters. With one parameter, say " | ||
+ | |||
+ | **Examples: | ||
+ | <code bauxite> | ||
+ | range(5) | ||
+ | </ | ||
+ | List of integers from 0 to, but not including, 5 (i.e. 0, 1, 2, 3, 4). | ||
+ | |||
+ | <code bauxite> | ||
+ | range(12, 15) | ||
+ | </ | ||
+ | List of integers from 12 to, but not including, 15 (i.e. 12, 13, 14). | ||
+ | |||
+ | <code bauxite> | ||
+ | range(0, 9, 2) | ||
+ | </ | ||
+ | List of integers from 0 to, but not including, 9, with an increment of 2 (i.e. 0, 2, 4, 6, 8). | ||
+ | |||
+ | <code bauxite> | ||
+ | range(5, 0, -1) | ||
+ | </ | ||
+ | List of integers from 5 to, but not including, 0, with an increment of -1 (i.e. 5, 4, 3, 2, 1). | ||
+ | |||
====Inverse==== | ====Inverse==== |