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/16 21:21] justinscript_syntax [2020/02/17 10:51] justin
Line 120: Line 120:
 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"]|
 +|Range|List of integers based on a set of parameters.|range(1, 5)|
 |Entities in a Group|List of all [[entity|entities]] assigned to a map [[groups|group]].|group["slimes"], group["trap_tiles"]| |Entities in a Group|List of all [[entity|entities]] assigned to a map [[groups|group]].|group["slimes"], group["trap_tiles"]|
 |Groups for an Entity|List of all [[groups|group]] to which an [[entity]] belongs.|self.groups, entity["some_id"].groups| |Groups for an Entity|List of all [[groups|group]] to which an [[entity]] belongs.|self.groups, entity["some_id"].groups|
 |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|
-|User-Defined|List of custom values declared with the "array" syntax.|array["A", "B", "C"]| 
  
 The values in an array can be iterated through using a "For" loop. You can also check to see if a particular value exists within an array using the "contains" operator in a [[conditional expression]]. See below for some example script usages. The values in an array can be iterated through using a "For" loop. You can also check to see if a particular value exists within an array using the "contains" operator in a [[conditional expression]]. See below for some example script usages.
Line 133: Line 134:
 end end
 </code> </code>
-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 "human" then if player.tags contains "human" then
Line 146: Line 147:
 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_listarray variable.
  
 ====Null==== ====Null====
Line 196: Line 197:
  
 ====Range==== ====Range====
-The **range** function generates an array of integers based on the supplied parameters. With one parameter, say "a", it creates a list starting with 0 and ending with one less than "a". With two parameters, say "a" and "b", it creates a list starting with "a" and ending with one less than "b". With three parameters, say "a", "b", and "c", it creates a list starting with "a", ending before "b" is reached, and incrementing by "c".  See below for some examples of each scenario.+The **range** function generates an [[array]] of integers based on the supplied parameters. With one parameter, say "a", it generates a list starting with 0 and ending with one less than "a". With two parameters, say "a" and "b", it generates a list starting with "a" and ending with one less than "b". With three parameters, say "a", "b", and "c", it generates a list starting with "a", incrementing by "c", and ending before "b" is reached.  See below for some examples of each scenario.
  
 +**Examples:**
 <code bauxite> <code bauxite>
 range(5) range(5)
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin