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/04/21 19:09] justinscript_syntax [2021/05/05 12:12] justin
Line 82: Line 82:
 while global.property["regen_hp"] do while global.property["regen_hp"] do
    player.stat["hp"] += 1;    player.stat["hp"] += 1;
-   wait(2) +   wait(2); 
-end+end;
 </code> </code>
  
Line 93: Line 93:
 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>
 +for $item_id in $item_list do
 +   give_item($item_id);
 +end;
 +</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.
 <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>
 Gives the following items to the player: one of ITEM_0001, two of ITEM_0002, and three of ITEM_0003. Gives the following items to the player: one of ITEM_0001, two of ITEM_0002, and three of ITEM_0003.
Line 131: Line 137:
 <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>
 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
-   display_message("No humans allowed!"+   display_message("No humans allowed!"); 
-end+end;
 </code> </code>
 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.
Line 145: Line 151:
 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 155: Line 161:
 <code bauxite> <code bauxite>
 if x == null then if x == null then
-   print("Variable x is not yet defined or has no value."+   print("Variable x is not yet defined or has no value."); 
-end+end;
 </code> </code>
 <code bauxite> <code bauxite>
 if entity["some_id"] != null then if entity["some_id"] != null then
-   remove_entity(entity["some_id"]) +   remove_entity(entity["some_id"]); 
-end+end;
 </code> </code>
 <code bauxite> <code bauxite>
Line 167: Line 173:
 $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>
  
Line 183: Line 189:
 **Examples:** **Examples:**
 <code bauxite> <code bauxite>
-wait(random(1, 5))+wait(random(1, 5));
 </code> </code>
 Waits for a random amount of time between 1 and 5 seconds. Waits for a random amount of time between 1 and 5 seconds.
Line 189: Line 195:
 <code bauxite> <code bauxite>
 if random(0, 100) <= 25 then if random(0, 100) <= 25 then
-  give_item("ITEM_0001")+  give_item("ITEM_0001");
 else else
-  give_item("ITEM_0002"+  give_item("ITEM_0002"); 
-end+end;
 </code> </code>
 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.
Line 233: Line 239:
 **Examples:** **Examples:**
 <code bauxite> <code bauxite>
-rotate_player_to_direction(inverse(entity["goblin"].direction))+rotate_player_to_direction(inverse(entity["goblin"].direction));
 </code> </code>
 Rotates the player character to be facing in the opposite direction that the goblin is facing. Rotates the player character to be facing in the opposite direction that the goblin is facing.
Line 243: Line 249:
 <code bauxite> <code bauxite>
 $counter += 1; $counter += 1;
-$new_tile_id = "tile" + str($counter)+$new_tile_id = "tile" + str($counter);
 </code> </code>
 <code bauxite> <code bauxite>
 $string_with_num = "17"; $string_with_num = "17";
-$new_value = num($string_with_num) + 1+$new_value = num($string_with_num) + 1;
 </code> </code>
  
-~~NOCACHE~~ 
 ~~NOTOC~~ ~~NOTOC~~
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin