Skip to content

Battle Script Functions

NightfallAlicorn edited this page Sep 5, 2015 · 2 revisions

Scripting/Battle/Functions

Since no one has made a page explaining battle script functions in more detail on here. I've decided to make a start with the information I've collected testing. Everyone is welcome to add more here.


Battle Commands

This section focuses of making the script trigger the command buttons during battle.

  • battle.attackClicked(int) Presses 1 of the 4 move buttons. The int is ranged from 0 to 3. 0 top-left, 1 top-right, 2 buttom-left and 3 buttom-right. Example: battle.attackClicked(1); will press the button on the top-right. If another move was selected first, the last move will need to be cancelled first before new move can be chosen.
  • battle.attackButton() Chooses the currently highlighted move button. If current option is Struggle, this will press it.
  • battle.offerTie() Sends request to tie current battle. The tie button will be pressed. If another button was pressed while waiting for opponent to make a turn, the last input will be cancelled and replaced with tie.
  • battle.emitCancel() Cancels the current move unless the opponent has already chosen a move.
  • battle.forfeit() Forfeits against your opponent and closes the battle window. Works even if a move was clicked and waiting for opponent.

Battle Messages

Stuff related to printing and sending messages in battle.

  • battle.battleMessage(battle.id, message) Use this to make the script send a message during the battle. battle.id is the unique id of the battle. But even if you use an id of another battle you're in, it won't communicate with another battle window making it useless. message is the message you want to send. Personally it's easier to break it down into a smaller function removing unnecessary length.
  • print(message) Prints messages in the battle window that only you can see. Handy for debugging purposes.

Battle Music & Sound

This section focuses on controlling the music and sounds of the battle.

  • battle.musicPlayStop() Stops the current soundtrack and plays the next random song in queue in the music directory folder.
  • battle.changeMusicVolume(int) Changes the music volume of the current and queued soundtracks, based on the int input. The int is ranged from 0 to 100. Example: battle.changeMusicVolume(50); will have it half maximum volume. Further note that it doesn't change the default setting under Sound Configuration menu. Turning music off and on by check box in battle will also reset volume to current setting in Sound Configuration menu.
  • battle.playCry(int) Plays the cry of a Pokemon. The int is the Pokemon's national Pokedex number of the cry. Example: battle.playCry(150); will play Mewtwo's cry. Note Music checkbox needs to be enabled for cries to play.

Battle Window

These functions manipulate the battle window itself.

  • battle.showMinimized() Minimises the battle window.
  • battle.setWindowTitle(string) Changes the battle window title to the string value.
  • battle.isActiveWindow Returns a boolean true if the battle window is currently selected or false if not. Handy if you want to make an alert to see if the opponent made their move yet.