Scripting reference

This page is a quick reference of scripting directives, useful for map-makers to see everything in one page.

Conditions

Below is the list of all conditions usable inside scripts, along with a description of their parameters, if any. In order to negate a condition, it is enough to replace is by not.

ButtonPressedCondition

Check to see if a particular key was pressed.

Currently only “K_RETURN” is supported.

Script usage

is button_pressed <button>
Script parameters

button – A button/intention key (E.g. “K_RETURN”).

CombatStartedCondition

Check to see if combat has been started or not.

Script usage

is combat_started

DialogOpenCondition

Check to see if a dialog window is open.

Script usage

is dialog_open

HasItemCondition

Check to see if a NPC inventory contains something.

Script usage

is has_item <character>,<item>[,operator][,quantity]
Script parameters
  • character – Either “player” or npc slug name (e.g. “npc_maple”).

  • item – The item slug name (e.g. “item_cherry”).

  • operator – Numeric comparison operator. Accepted values are “less_than”, “greater_than”, “equals”, “less_or_equal” and “greater_or_equal”. The default value is “greater_or_equal”.

  • quantity – Quantity to compare with. Must be a non-negative integer. The default value is 1.

HasMonsterCondition

Check to see the player is has a monster in his party.

Script usage

is has_monster <monster>
Script parameters

monster – Monster slug name (e.g. “rockitten”).

MonsterFlairCondition

Check to see if the given monster flair matches the expected value.

Script usage

is monster_flair <slot>,<category>,<name>
Script parameters
  • slot – Position of the monster in the player monster list.

  • category – Category of the flair.

  • name – Name of the flair.

MonsterPropertyCondition

Check to see if a monster property or condition is as asked.

Script usage

is monster_property <slot>,<property>,<value>
Script parameters
  • slot – Position of the monster in the player monster list.

  • property – Property of the monster to check (e.g. “level”). Valid values are:

    • name

    • level

    • level_reached

    • type

    • category

    • shape

  • value – Value to compare the property with.

MusicPlayingCondition

Check to see if a particular piece of music is playing or not.

Script usage

is music_playing <music_filename>
Script parameters

music_filename – Name of the music.

NPCAtCondition

Check to see if a character is at the condition position on the map.

Script usage

is npc_at <character>
Script parameters

character – Either “player” or npc slug name (e.g. “npc_maple”).

NPCExistsCondition

Check to see if a character object exists in the current list of NPCs.

Script usage

is npc_exists <character>
Script parameters

character – Either “player” or npc slug name (e.g. “npc_maple”).

NPCFacingTileCondition

Check to see if a character is facing a tile position.

This is checked against all the tiles included in the condition object.

Script usage

is npc_facing_tile <character>
Script parameters

character – Either “player” or npc slug name (e.g. “npc_maple”).

NPCFacingCondition

Check to see where a character is facing.

Script usage

is npc_facing <character>,<direction>
Script parameters
  • character – Either “player” or npc slug name (e.g. “npc_maple”).

  • direction – One of “up”, “down”, “left” or “right”.

PartySizeCondition

Check the party size.

Script usage

is party_size <operator>,<value>
Script parameters
  • operator – One of “equals”, “less_than” or “greater_than”.

  • value – The value to compare the party size with.

PlayerAtCondition

Check to see if the player is at the condition position on the map.

Script usage

is player_at

PlayerDefeatedCondition

Check to see the player has at least one tuxemon, and all tuxemon in their party are defeated.

Script usage

is player_defeated

PlayerFacingNPCCondition

Check to see the player is next to and facing a particular NPC.

Script usage

is player_facing_npc <character>
Script parameters

character – Npc slug name (e.g. “npc_maple”).

PlayerFacingTileCondition

Check to see if an NPC is facing a tile position.

Script usage

is player_facing_tile

PlayerFacingCondition

Check to see where an NPC is facing.

Script usage

is player_facing <direction>
Script parameters

direction – One of “up”, “down”, “left” or “right”.

ToTalkCondition

Check if we are attempting to talk to an npc.

Script usage

is to_talk <character>
Script parameters

character – Npc slug name (e.g. “npc_maple”).

ToUseTileCondition

Check if we are attempting interact with a map condition tile.

Script usage

is to_use_tile

TrueCondition

This condition always returns true.

Script usage

is true

VariableIsCondition

Check an operation over a variable.

Script usage

is variable_is <value1>,<operation>,<value2>
Script parameters
  • value1 – Either a variable or a number.

  • operation – One of “==”, “!=”, “>”, “>=”, “<” or “<=”.

  • value2 – Either a variable or a number.

VariableSetCondition

Check to see if a player game variable exists and has a particular value.

If the variable does not exist it will return False.

Script usage

is variable_set <variable>[:value]
Script parameters
  • variable – The variable to check.

  • value – Optional value to check for.

Actions

Below is the list of all actions usable inside scripts, along with a description of their parameters, if any.

AddItemAction

Add an item to the current player’s inventory.

Script usage

add_item <item_slug>[,quantity]
Script parameters
  • item_slug – Item name to look up in the item database.

  • quantity – Quantity of the item to add. By default it is 1.

CallEventAction

Execute the specified event’s actions by id.

Script usage

call_event <event_id>
Script parameters

event_id – The id of the event whose actions will be executed.

ChangeStateAction

Change to the specified state.

Script usage

change_state <state_name>
Script parameters

state_name – The state name to switch to (e.g. PCState).

ClearVariableAction

Clear the value of a variable from the game.

Script usage

clear_variable <variable>
Script parameters

variable – The variable to clear.

CopyVariableAction

Copy the value of var2 into var1 (e.g. var1 = var 2).

Script usage

copy_variable <var1>,<var2>
Script parameters
  • var1 – The variable to copy to.

  • var2 – The variable to copy from.

FadeoutMusicAction

Fade out the music over a set amount of time in milliseconds.

Script usage

fadeout_music <duration>
Script parameters

duration – Number of milliseconds to fade out the music over.

NpcMoveAction

Relative tile movement for NPC.

This action blocks until the destination is reached.

Script usage

npc_move <npc_slug>,<move>...
Script parameters
  • npc_slug – Either “player” or npc slug name (e.g. “npc_maple”).

  • move – A tuple with format <direction> [amount_of_tiles] where direction can be one of “up”, “down”, “left” and “right” and amount_of_tiles is the number of tiles moved in that direction, being 1 by default. Several movements can be passed, that will be executed one after the other. For example: up 10, down 5, left 5.

NpcRun

Set the NPC movement speed to the global run speed.

Script usage

npc_run <npc_slug>
Script parameters

npc_slug – Either “player” or npc slug name (e.g. “npc_maple”).

NpcSpeed

Set the NPC movement speed to a custom value.

Script usage

npc_speed <npc_slug> <speed>
Script parameters
  • npc_slug – Either “player” or npc slug name (e.g. “npc_maple”).

  • speed – Speed amount.

NpcWalk

Set the NPC movement speed to the global walk speed.

Script usage

npc_walk <npc_slug>
Script parameters

npc_slug – Either “player” or npc slug name (e.g. “npc_maple”).

PathfindAction

Pathfind the player / npc to the given location.

This action blocks until the destination is reached.

Script usage

pathfind <npc_slug>
Script parameters

npc_slug – Either “player” or npc slug name (e.g. “npc_maple”).

PauseMusicAction

Pause the current music playback.

Script usage

pause_music

PrintAction

Print the current value of a game variable to the console.

If no variable is specified, print out values of all game variables.

Script usage

print
print <variable>
Script parameters:

variable: Optional, prints out the value of this variable.

QuitAction

Completely quit the game.

Script usage

quit

RandomIntegerAction

Randomly choose an integer between 2 numbers (inclusive), and set the key in the player.game_variables dictionary to be this value.

For example, ‘random_integer xyz,1,6’ will set the value of the game variable ‘xyz’ to be either 1, 2, 3, 4, 5, or 6.

Script usage

random_integer <variable>,<lower_bound>,<upper_bound>
Script parameters
  • variable – Name of the variable.

  • lower_bound – Lower bound of range to return an integer between (inclusive)

  • upper_bound – Upper bound of range to return an integer between (inclusive)

RemoveMonsterAction

Remove a monster from the given trainer’s party if the monster is there.

Monster is determined by instance_id, which must be passed in a game variable.

Script usage

remove_monster <instance_id>[,trainer_slug]
Script parameters
  • instance_id – Id of the monster.

  • trainer_slug – Slug of the trainer. If no trainer slug is passed it defaults to the current player.

RumbleAction

Rumble available controllers with rumble support.

Script usage

rumble <duration>,<power>
Script parameters
  • duration – Time in seconds to rumble for.

  • power – Percentage of power to rumble.

SetMonsterLevelAction

Change the level of a monster in the current player’s party.

Script usage

set_monster_level [slot][,level]
Script parameters
  • slot – Slot of the monster in the party. If no slot is specified, all monsters are leveled.

  • level – Number of levels to add. Negative numbers are allowed.

SetVariableAction

Set the key in the player.game_variables dictionary.

Script usage

set_variable <variable>:<value>
Script parameters
  • variable – Name of the variable.

  • value – Value of the variable.

StoreMonsterAction

Store a monster in a box.

Save the player’s monster with the given instance_id to the named storage box, removing it from the player party.

Script usage

store_monster <monster_id>,<box>
Script parameters
  • monster_id – Id of the monster to store.

  • box – Box where the monster will be stored.

TeleportFaintAction

Teleport the player to the point in the teleport_faint variable.

Usually used to teleport to the last visited Tuxcenter, as when all monsters in the party faint.

Script usage

teleport_faint

VariableMathAction

Perform a mathematical operation on the player.game_variables dictionary.

Optionally accepts a fourth parameter to store the result, otherwise it is stored in var1.

Script usage

variable_math <var1>,<operation>,<var2>,<result>
variable_math <var1>,<operation>,<var2>
Script parameters
  • var1 – First operand.

  • operation – Operator symbol.

  • var2 – Second operand.

  • result – Variable where to store the result. If missing, it will be var1.

WaitAction

Block event chain for some time.

Script usage

wait <seconds>
Script parameters

seconds – Time in seconds for the event engine to wait for.