NAV
lua

Introduction

Welcome to the API documentation for PROShine.

This documentation describes the functions available for use in the Lua scripts.

Please note that functions are case-sensitive in Lua and all the PROShine functions start with a lowercase letter.

Last updated: June 01, 2016

General functions

Log

function log(message)

log("Hello! This is a message.")
log("I have " .. getTeamSize() .. " pokémon in my team.")

Writes the specified message to the message log.

PARAMETERS

Parameter Type Description
message string Message to display

Fatal

function fatal(message)

fatal("You are not on the correct map, stopping the script!")

Writes the specified message to the message log and stops the bot.

PARAMETERS

Parameter Type Description
message string Message to display

StringContains

function stringContains(haystack, needle)

Returns true if the haystack contains the specified needle, ignoring the case.

PARAMETERS

Parameter Type Description
haystack string String to analyze
needle string String to search in the haystack

Game conditions

GetPlayerX

function getPlayerX()

Returns the X-coordinate of the current cell.

GetPlayerY

function getPlayerY()

Returns the Y-coordinate of the current cell.

GetMapName

function getMapName()

Returns the name of the current map.

GetTeamSize

function getTeamSize()

Returns the amount of pokémon in the team.

GetPokemonId

function getPokemonId(index)

Returns the pokédex ID of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetPokemonName

function getPokemonName(index)

Returns the name of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetPokemonHealth

function getPokemonHealth(index)

Returns the current health of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetPokemonHealthPercent

function getPokemonHealthPercent(index)

Returns the percentage of remaining health of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetPokemonLevel

function getPokemonLevel(index)

Returns the level of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetPokemonStatus

function getPokemonStatus(index)

Returns the status of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

IsPokemonUsable

function isPokemonUsable(index)

Returns true if the specified pokémon is alive and has an offensive attack available.

PARAMETERS

Parameter Type Description
index number Index of the pokémon (1-6).

GetUsablePokemonCount

function getUsablePokemonCount()

Returns the amount of usable pokémon in the team.

HasMove

function hasMove(pokemonIndex, moveName)

Returns true if the specified pokémon has a move with the specified name.

PARAMETERS

Parameter Type Description
pokemonIndex number Index of the pokémon (1-6).
moveName string Name of the move (case insensitive).

GetRemainingPowerPoints

function getRemainingPowerPoints(pokemonIndex, moveName)

Returns the remaining power points of the specified move of the specified pokémon in the team.

PARAMETERS

Parameter Type Description
pokemonIndex number Index of the pokémon (1-6).
moveName string Name of the move (case insensitive).

HasItem

function hasItem(itemName)

Returns true if the specified item is in the inventory.

PARAMETERS

Parameter Type Description
itemName string Name of the item (case insensitive).

GetItemQuantity

function getItemQuantity(itemName)

Returns the quantity of the specified item in the inventory.

PARAMETERS

Parameter Type Description
itemName string Name of the item (case insensitive).

HasPokemonInTeam

function hasPokemonInTeam(pokemonName)

Returns true if the specified pokémon is present in the team.

PARAMETERS

Parameter Type Description
pokemonName string Name of the pokémon (case insensitive).

IsTeamSortedByLevelAscending

function isTeamSortedByLevelAscending()

Returns true if the team is sorted by level in ascending order.

IsTeamSortedByLevelDescending

function isTeamSortedByLevelDescending()

Returns true if the team is sorted by level in descending order.

IsTeamRangeSortedByLevelAscending

function isTeamRangeSortedByLevelAscending(fromIndex, toIndex)

Returns true if the specified part of the team is sorted by level in ascending order.

PARAMETERS

Parameter Type Description
fromIndex number Lower index of the range (1-5).
toIndex number Upper index of the range (2-6).

IsTeamRangeSortedByLevelDescending

function isTeamRangeSortedByLevelDescending(fromIndex, toIndex)

Returns true if the specified part of the team the team is sorted by level in descending order.

PARAMETERS

Parameter Type Description
fromIndex number Lower index of the range (1-5).
toIndex number Upper index of the range (2-6).

IsNpcVisible

function isNpcVisible(npcName)

Returns true if there is a visible NPC with the specified name on the map.

If the NPC is a pokémon, its name is the character # followed by the pokédex ID.

PARAMETERS

Parameter Type Description
npcName string Name of the NPC (case insensitive).

IsNpcOnCell

function isNpcOnCell(cellX, cellY)

Returns true if there is a visible NPC the specified coordinates.

PARAMETERS

Parameter Type Description
cellX number X coordinate of the cell.
cellY number Y coordinate of the cell.

IsShopOpen

function isShopOpen()

Returns true if there is a shop opened.

GetMoney

function getMoney()

Returns the amount of money in the inventory.

IsMounted

function isMounted()

Returns true if the player is riding a mount or the bicycle.

Battle conditions

IsOpponentShiny

function isOpponentShiny()

Returns true if the opponent pokémon is shiny.

IsAlreadyCaught

function isAlreadyCaught()

Returns true if the opponent pokémon has already been caught and has a pokédex entry.

IsWildBattle

function isWildBattle()

Returns true if the current battle is against a wild pokémon.

GetActivePokemonNumber

function getActivePokemonNumber()

Returns the index of the active team pokémon in the current battle.

GetOpponentId

function getOpponentId()

Returns the id of the opponent pokémon in the current battle.

GetOpponentName

function getOpponentName()

Returns the name of the opponent pokémon in the current battle.

GetOpponentHealth

function getOpponentHealth()

Returns the current health of the opponent pokémon in the current battle.

GetOpponentHealthPercent

function getOpponentHealthPercent()

Returns the percentage of remaining health of the opponent pokémon in the current battle.

GetOpponentLevel

function getOpponentLevel()

Returns the level of the opponent pokémon in the current battle.

getOpponentStatus

function getOpponentStatus()

Returns the status of the opponent pokémon in the current battle.

IsOpponentEffortValue

function isOpponentEffortValue(statType)

Returns true if the opponent is only giving the specified effort value.

The valid values for the stat type are:

Full name Short Alternative
Health HP
Attack ATK
Defence DEF Defense
SpAttack SPATK
SpDefence SPDEF SpDefense
Speed SPD

PARAMETERS

Parameter Type Description
statType string Name of the stat (case insensitive).

Game actions

MoveToCell

function moveToCell(cellX, cellY)

Moves to the specified coordinates.

PARAMETERS

Parameter Type Description
cellX number X coordinate of the cell
cellY number Y coordinate of the cell

MoveToMap

function moveToMap(mapName)

Moves to the nearest cell teleporting to the specified map.

PARAMETERS

Parameter Type Description
mapName string Name of the destination map (case insensitive)

MoveToRectangle

function moveToRectangle(minX, minY, maxX, maxY)

Moves to a random accessible cell inside the specified rectangle.

PARAMETERS

Parameter Type Description
mapName string Name of the destination map (case insensitive)

MoveToGrass

function moveToGrass()

Moves to the nearest grass patch then moves randomly inside it.

MoveToWater

function moveToWater()

Moves to the nearest water area then moves randomly inside it.

MoveNearExit

function moveNearExit(mapName)

Moves near the cell teleporting to the specified map.

PARAMETERS

Parameter Type Description
mapName string Name of the map (case insensitive)

TalkToNpc

function talkToNpc(npcName)

Moves then talks to NPC specified by its name.

If the NPC is a pokémon, its name is the character # followed by the pokédex ID.

PARAMETERS

Parameter Type Description
mapName string Name of the NPC (case insensitive)

TalkToNpcOnCell

function talkToNpcOnCell(cellX, cellY)

Moves then talks to NPC located on the specified cell.

PARAMETERS

Parameter Type Description
cellX number X coordinate of the cell
cellY number Y coordinate of the cell

UsePokecenter

function usePokecenter()

Moves to the Nurse Joy then talks to the cell below her.

SwapPokemon

function swapPokemon(index1, index2)

Swaps the two pokémon specified by their position in the team.

PARAMETERS

Parameter Type Description
index1 number Index of the first pokémon to swap
index2 number Index of the second pokémon to swap

SwapPokemonWithLeader

function swapPokemonWithLeader(pokemonName)

Swaps the first pokémon with the specified name with the leader of the team.

PARAMETERS

Parameter Type Description
pokemonName string Name of the pokémon to swap with the leader (case insensitive)

SortTeamByLevelAscending

function sortTeamByLevelAscending()

Sorts the pokémon in the team by level in ascending order, one pokémon at a time.

SortTeamByLevelDescending

function sortTeamByLevelDescending()

Sorts the pokémon in the team by level in descending order, one pokémon at a time.

SortTeamRangeByLevelAscending

function sortTeamRangeByLevelAscending(fromIndex, toIndex)

Sorts the specified part of the team by level in ascending order, one pokémon at a time.

SortTeamRangeByLevelDescending

function sortTeamRangeByLevelDescending(fromIndex, toIndex)

Sorts the specified part of the team by level in descending order, one pokémon at a time.

BuyItem

function buyItem(itemName, quantity)

buyItem("Potion", 1) -- Buys one Potion
buyItem("Poke Ball", 307) -- Buys 307 Poke Ball

Buys the specified item from the opened shop.

PARAMETERS

Parameter Type Description
itemName string Name of the item to buy (case insensitive)
quantity number Quantity of items to buy

Battle actions

Attack

function attack()

Uses the most effective offensive move available.

WeakAttack

function weakAttack()

Uses the least effective offensive move available.

Run

function run()

Tries to escape from the current wild battle.

SendUsablePokemon

function sendUsablePokemon()

Sends the first usable pokemon different from the active one.

SendPokemon

function sendPokemon(index)

Sends the specified pokemon to battle.

PARAMETERS

Parameter Type Description
index number Index of pokémon to send

UseMove

function useMove(moveName)

Uses the specified move in the current battle if available.

PARAMETERS

Parameter Type Description
moveName string Name of the move to use (case insensitive)

Other actions

PushDialogAnswer

function pushDialogAnswer(answerIndex)

pushDialogAnswer(2)
pushDialogAnswer(1)
pushDialogAnswer(3)
talkToNpc("Jackson") -- Will select 2, 1 then 3.

Adds the specified answer to the answer queue. It will be used in the next dialog.

This function should be called before a talkToNpc or talkToNpcOnCell.

PARAMETERS

Parameter Type Description
answerIndex number Index of the answer or index of the pokémon to select

UseItem

function useItem(itemName)

useItem("Bicycle")
useItem("Escape Rope")

Uses the specified item.

This function is usable in the field and in battle.

PARAMETERS

Parameter Type Description
itemName string Name of the item (case insensitive)

UseItemOnPokemon

function useItemOnPokemon(itemName, pokemonIndex)

useItemOnPokemon("Potion", 1)
useItemOnPokemon("Rare Candy", 5)

Uses the specified item on the specified pokémon.

This function is usable in the field and in battle.

PARAMETERS

Parameter Type Description
itemName string Name of the item (case insensitive)
pokemonIndex number Index of the pokémon (1-6)

ForgetMove

function forgetMove(moveName)

forgetMove("Dragon Rage")

Only usable when learning a move, inside onMoveLearning.

Forgets the specified move, if existing, in order to learn a new one.

PARAMETERS

Parameter Type Description
moveName string Name of the move (case insensitive)

ForgetAnyMoveExcept

function forgetAnyMoveExcept(moveNames)

forgetAnyMoveExcept({"Fly", "Cut", "Psychic", "Thunder"})

Only usable when learning a move, inside onMoveLearning.

Forgets the first move that is not one of the specified moves.

PARAMETERS

Parameter Type Description
moveNames array of string Name of the moves (case insensitive)

Events

onStart

function onStart()

Called when the bot is started.

This is where you should initialize your variables.

onStop

function onStop()

Called when the bot is stopped.

onPause

function onPause()

Called when the bot is paused.

onResume

function onPause()

Called when the bot is resumed from a previous pause.

onPathAction

function onPathAction()

Called when the bot must execute a path action.

You should execute one (and only one) game action in this scope.

onBattleAction

function onBattleAction()

Called when the bot must execute a batlle action.

You should execute one (and only one) battle action in this scope.

onDialogMessage

function onDialogMessage(message)

Called when a dialog message is displayed (because you are talking to a NPC, for instance).

onBattleMessage

function onBattleMessage(message)

Called when a battle message is displayed.

These messages are displayed inside the battle window in-game.

onSystemMessage

function onSystemMessage(message)

Called when a system message is displayed.

These messages are displayed inside the chat in-game.

onLearningMove

function onLearningMove(moveName, pokemonIndex)

Called when a pokémon is learning a move but already has four.

You can call forgetMove or forgetAnyMoveExcept here.

If you do not call these functions, the move will not be learned.

PARAMETERS

Parameter Type Description
moveName string Name of the move that can be learned
pokemonIndex number Index of the pokémon learning that move
lua