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”.

  • quantity – Quantity to compare with.

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.

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 – Numeric comparison operator. Accepted values are “less_than”, “less_or_equal”, “greater_than”, “greater_or_equal”, “equals” and “not_equals”.

  • 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”).

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”).

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.

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.

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.

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 (if value “today” = today’s date)

StartCinemaModeAction

Start cinema mode by animating black bars to narrow the aspect ratio.

Script usage

start_cinema_mode

StopCinemaModeAction

Stop cinema mode by animating black bars back to the normal aspect ratio.

Script usage

stop_cinema_mode

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.