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 18:10] – justin | script_syntax [2020/02/18 17:38] – 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^ | ||
+ | |User-Defined|List of custom values declared with the " | ||
+ | |Range|List of integers based on a set of parameters.|range(1, | ||
|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[" | ||
|Groups for an Entity|List of all [[groups|group]] to which an [[entity]] belongs.|self.groups, | |Groups for an Entity|List of all [[groups|group]] to which an [[entity]] belongs.|self.groups, | ||
|Tags for an Entity|List of tags assigned to an [[entity|entity' | |Tags for an Entity|List of tags assigned to an [[entity|entity' | ||
- | |User-Defined|List of custom values declared with the " | ||
- | The values in an array can be iterated through using a " | + | The values in an [[array]] can be iterated through using a " |
- | ====Examples:==== | + | **Examples:** |
<code bauxite> | <code bauxite> | ||
- | for slime in group[" | + | for slime_entity |
- | | + | |
end | end | ||
</ | </ | ||
- | Deals 2 damage to all entities in the "Slimes" [[groups|group]]. | + | Deals 2 damage to all entities in the "slimes" [[groups|group]]. |
<code bauxite> | <code bauxite> | ||
if player.tags contains " | if player.tags contains " | ||
Line 138: | Line 147: | ||
give_item(item_list[random(0, | give_item(item_list[random(0, | ||
</ | </ | ||
- | 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 148: | Line 181: | ||
The **random number** function generates an integer value within the given range (inclusive of the minimum and maximum value). It can be used in scripts anywhere a numeric value is expected or allowed. | The **random number** function generates an integer value within the given range (inclusive of the minimum and maximum value). It can be used in scripts anywhere a numeric value is expected or allowed. | ||
- | ====Examples:==== | + | **Examples:** |
<code bauxite> | <code bauxite> | ||
wait(random(1, | wait(random(1, | ||
Line 162: | Line 195: | ||
</ | </ | ||
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==== | ||
Line 174: | Line 231: | ||
|[[navigation_and_interaction|Navigation Type]]|inverse(WALK_AND_INTERACT) will return PENDING| | |[[navigation_and_interaction|Navigation Type]]|inverse(WALK_AND_INTERACT) will return PENDING| | ||
- | ====Examples:==== | + | **Examples:** |
<code bauxite> | <code bauxite> | ||
rotate_player_to_direction(inverse(entity[" | rotate_player_to_direction(inverse(entity[" |