Lua Function Reference

From PMDOWiki
(Redirected from Script Reference)

This is a reference page of all the functions that can be called in Lua and their namespaces. See the main page for each namespace for further details.

AI

Main article: AI (functions)
Function Description
SetCharacterAI Gives the ground character the assigned AI.
DisableCharacterAI Disables the AI processing of the ground character.
EnableCharacterAI Enables the AI processing of the ground character, if it has been disabled by DisableCharacterAI.
SetAIState ???

Dungeon

Main article: Dungeon (functions)
Function Description
CharTurnToChar Makes a character turn to face another.
LastDungeonResult Gets the result of the last dungeon adventure.
DungeonCurrentFloor Returns the floor number of the current dungeon.
DungeonAssetName Returns the internal name for the current dungeon.
DungeonDisplayName Returns the localized name of the current dungeon.
CharSetEmote Set a character's emote in a dungeon map.
CharStartAnim Set a character's animation.
CharEndAnim Stops a character's current animation, reverting them to default idle.
PlayVFX Plays a VFX in the dungeon map
PlayVFX Plays a VFX that has a start position and an end position. It uses a finite emitter that generates BaseAnims.
MoveScreen Plays a screen-moving effect.

Game

Main article: Game (functions)

Game Control

Function Description
GroundSave Saves the game while in ground mode.
GetModDiff (undocumented)
RestartToTitle Leave the current map and load the title screen.
RestartRogue Restarts a roguelocke run based on the configuration.
CutsceneMode Turns cutscene mode on or off.

Map and Adventure Control

Function Description
GetCurrentGround Returns the current ground map.
GetCurrentFloor Returns the current dungeon map.
GetCurrentDungeon Returns the current zone (aka dungeon).
EnterGroundMap Enter the specified ground map.
EnterDungeon Enter the specified dungeon.
ContinueDungeon Enter the zone and continue the current ongoing adventure.
EndDungeonRun Enter the zone and continue the current ongoing adventure.
EnterZone Enter the zone and begin an adventure.

Rescue Management

Function Description
EnterRescue Enter a zone and begin a rescue.
AddAOKRemark (Undocumented)
HasSOSMail (Undocumented)
HasAOKMail (Undocumented)
GetRescueAllowed Returns true if rescues are allowed, false otherwise.
SetRescueAllowed Sets a flag in the player's save file to determined if they can be rescued or not.

Camera & Scene Control

Function Description
FadeOut Fades screen out, waits to finish.
FadeIn Fades screen in, waits to finish.
MoveCamera Moves the camera.
MoveCameraToChara Moves the camera to the specified character.
GetCameraCenter Returns the current center of the camera.
IsCameraOnChar Returns true if the camera is centered relative to the player, false if not.

Team Management

Function Description
GetTeamLeaderIndex Returns the index of the currently player controlled entity in the party.
SetTeamLeaderIndex Sets the leader to the chosen index in the party.
SetCanSwitch Configure the ability to switch leaders in the save file.
SetCanRecruit Configure the ability to recruit in the save file.
SetTeamName Sets the name of the player's team.
GetTeamName Gets the name of the player's team. Returns the name of the team.

Party Management

Function Description
GetPlayerPartyCount Returns the player's party count.
GetPlayerPartyTable Returns the player's party as a lua table, excluding guests.
GetPlayerPartyMember Returns the party member at the specified team index.
AddPlayerTeam Adds the given character to the player's team.
RemovePlayerTeam Removes the character from the given slot from the team.

Assembly Management

Function Description
GetPlayerAssemblyCount Returns the amount of characters currently in the player's assembly.
GetPlayerAssemblyTable Returns the player's assembly as a lua table.
GetPlayerAssemblyMember Gets the character at the specified index from the assembly.
AddPlayerAssembly Adds the given character to the player's assembly.
RemovePlayerAssembly Removes the character from the given slot from the assembly.

Guest Management

Function Description
GetPlayerGuestCount Returns the amount of guests currently in the player's party.
GetPlayerGuestTable Returns the player's party guests as a lua table.
GetPlayerGuestMember Gets the character at the specified index from the guests.
AddPlayerGuest Adds the given character to the player's guest list.
RemovePlayerGuest Removes the character from the given slot from the guest list.

Character Control

Function Description
SetCharacterNickname Sets a character's nickname.
GetCharacterNickname Returns the nickname of the passed character.
CanRelearn Checks if the character can relearn any skills. Returns true if they can, false if they can't.
CanForget Checks if the character can forget any skills. Returns true if they can, false if they can't.
CanLearn Checks if the character can learn any skills.
CheckLevelSkills Checks the levels gained by a character and prompts to learn all skills along the levels.
TryLearnSkill Attempts to give a new skill to the specified character, prompting to replace an old one if they are full.
LearnSkill Gives a new skill to a specified character. Fails if the character's skills are full.
ForgetSkill Removes a skill from the specified character.
LockSkill Makes a skill impossible to forget or replace for the specified character.
UnlockSkill Unlocks a previously locked skill for the specified character, making it possible to be forgotten or replaced during normal gameplay.
SetCharacterSkill Gives a new skill to a specified character, replacing a specifically chosen slot.
GetCharacterSkill Gets the skill from a specified character and specified slot.
CanPromote Checks if the character can be promoted to a new class. (In PMDO, this is evolution.)
GetAvailablePromotions Gets a list of possible classes that the character can promote to. (In PMDO, this is evolution.)
PromoteCharacter Promotes a character to a new class. (In PMDO, this is evolution.)

Item Management

Function Description
FindPlayerItem Finds an item in the player's team and returns its slot within the inventory or among its team's equips.
GetPlayerEquippedCount Returns the number of items equipped by players. Does not include guests.
GetPlayerBagCount Returns the number of items in the bag.
GetPlayerBagLimit Returns the maximum amount of item the player's team can carry.
GetPlayerEquippedItem Returns the equipped item for the character in the specified slot.
GetGuestEquippedItem Returns the equipped item for the character in the specified guest slot.
GivePlayerItem Gives an item and adds it to the player team's bag.
GetPlayerBagItem Returns the item found at the specified slot of the player's bag.
TakePlayerBagItem Remove an item from player's inventory.
akePlayerEquippedItem Remove the equipped item from a chosen member of the team.
TakeGuestEquippedItem Remove the equipped item from a chosen guest of the team.
GetPlayerStorageCount Returns the amount of items in the player's storage
GetPlayerStorageItemCount Returns the amount of a specific item in the player's storage
GivePlayerStorageItem Returns an item and adds it to the player team's storage.
GivePlayerStorageItem Gives an item and adds it to the player team's storage.
TakePlayerStorageItem Takes an item from the storage
DepositAll Takes all items in the player team's bag and equipped items, and deposits them in storage.

Money

Function Description
GetPlayerMoney Returns the amount of money the player currently has on hand.
AddToPlayerMoney Adds money to the player's wallet.
RemoveFromPlayerMoney Removes money from the player's wallet.
AddToPlayerMoneyBank Adds money to the player's bank.
RemoveFromPlayerMoneyBank Removes money from the player's bank.

Inputs

Function Description
IsKeyDown Checks if a player is making a certain physical keyboard input. Returns true if the button is currently being pressed, false otherwise.
IsInputDown Checks if a player is making a certain game input. Returns true if the input is currently pressed, false otherwise.

Dungeons

Function Description
GetDailySeed Returns the random seed for the current adventure.
UnlockDungeon Unlocks the specified dungeon.
DungeonUnlocked Returns true if the specified dungeon is unlocked, false if not.

Direction

Function Description
VectorToDirection Convenience function to get a vector's components from lua numbers. May take either a single integer or a vector in an X and Y value.
RandomDirection Generates a random direction. Returns an 8-directional direction.

Queuing

Function Description
QueueLeaderEvent Prepares an event to execute on the next frame.
WaitFrames Waits for a specified number of frames before continuing.

Ground

Main article: Ground (functions)

Entity

Function Description
Hide Hides an entity.
Unhide Unhides an entity.
CreateObject (undocumented)
CreateCharacter (undocumented)
RemoveObject Deletes an object from the ground map, identified by its instance name.
RemoveCharacter Deletes a character from the ground map, identified by its instance name.
CreateCharacterFromCharData Creates a ground character, given a dungeon character.
RefreshPlayer Reloads the controllable player's character data to be the current team's leader.
SetPlayer Sets the controllable player to use new character data.
SpawnerDoSpawn Make the specified spawner run its spawn method.
SpawnerSetSpawn Sets the character to the specified spawner.

Entity Turning

Function Description
CharTurnToChar Makes a character turn to face another character instantly.
CharTurnToCharAnimated Makes a character do an animated turn to face another character over the specified time.
EntTurn Makes a ground entity turn to face a direction.
CharAnimateTurn Makes a character do an animated turn to face a chosen direction over the specified time.
CharAnimateTurnTo Makes a character do an animated turn to face a chosen direction over the specified time.

Entity Movement

Function Description
TeleportTo Repositions the ground entity in a specified location.
MoveInDirection Make ground character move in a direction.
MoveToPostition Make ground character move to a position.
MoveToMarker Make ground character move to a ground marker.
MoveObjectToPosition Make ground object move to a position.
AnimateInDirection Make a ground character move in a direction with custom animation
AnimateToPosition Make a ground entity move to a position with custom animation

Entity Animation

Function Description
CharSetEmote Make a character emote on the ground map.
CharSetDrawEffect Sets the ground character's draw effect to become invisible, shaking, still, etc.
CharEndDrawEffect Ends the character's draw effect.
CharGetAnimFallback Gets the fallback animation for the character.
CharGetAnim Gets a character's current animation as a string.
CharGetAnimPoint Gets the chosen action point of the character at this specific frame.
CharSetAnim Set a character's animation.
CharEndAnim Stops a character's current animation, reverting them to default idle.
CharWaitAnim Makes the character perform an animation and waits until it's over.
CharSetAction Set a character's action.
CharWaitAction Makes the character perform an action and waits until it's over.
ObjectSectAnim Sets a ground object's animation. After it finishes, it will return to the default animation.
ObjectSetDefaultAnim Sets a ground object's default animation.
ObjectWaitAnimFrame Waits for the object to reach a specific frame before continuing.

Screen Effects

Function Description
PlayVFX Plays a VFX using a finite emitter that generates BaseAnims.
PlayVFX Plays a VFX that has a start position and an end position. It uses a finite emitter that generates BaseAnims.
PlayVFXAnim Plays a VFX using just a BaseAnim
MoveScreen Plays a screen-moving effect.

Leveling

Function Description
HandoutEXP Gives a character a set amount of EXP. Also handles leveling up and learning new moves.
LevelUpChar Levels up a character a certain amount of times all at once. Also handles learning new moves.

Map Status

Function Description
AddMapStatuses Adds a mapstatus to the ground map. Map statuses only have an aesthetic effect in ground maps.
RemoveMapStatuses Removes a map status from the ground map.

Sound

Main article: Sound (functions)
Function Description
PlayBattleSE Plays a sound effect specifically from the Battle/ subdirectory.
WaitSE Plays a sound effect, and waits for it to complete before continuing.
LoopSE Plays a continuous sound effect.
LoopBattleSE Plays a continuous sound effect.
StopSE Stops a continuous sound effect.
StopBattleSE Stops a continuous sound effect.
FadeInSE Plays a continuous sound effect, fading in over a specified amount of time.
FadeInBattleSE Plays a continuous sound effect, fading in over a specified amount of time.
FadeOutSE Stops a continuous sound effect, fading out over a specified amount of time.
FadeOutBattleSE Stops a continuous sound effect, fading out over a specified amount of time
PlayFanfare Plays a sound effect that temporarily mutes the music for its duration.
WaitFanfare Plays a sound effect that temporarily mutes the music for its duration.
PlayBGM Plays a song, replacing the current one.
StopBGM Stops playing the current song. Takes no arguments.
FadeOutBGM Fades out the current song.
SetBGMVolume Sets the current volume of the song.
GetCurrentSong Gets the currently playing song. If the current song is fading out, gets the next song to be played.

Strings

Main article: Strings (functions)
Function Description
LocaleCode Returns the current language setting of the game, represented by a locale code.
Format Formats a string. Will unescape escaped characters and process grammar tags. Returns the formatted string.
FormatKey Formats a string given a string key. Will unescape escaped characters.
LocalKeyString Returns the string representing a button or key.
CreateList Builds and returns a single string of comma separated elements.

Task

Main article: Task (functions)
Function Description
StartEntityTask Helper function to make an entity run the specified task. Will not replace a running task!
StopEntityTask Helper function to force stop an entity's current task.
WaitStartEntityTask Makes an entity run a specified task, and waits for it to complete before continuing.
WaitEntityTask Waits for the specified entity to finish its task.
WaitTask Runs a task and waits for it to complete. Most methods that do not expose themselves to script need to be wrapped with thi
StartScriptLocalCoroutine A wrapper around the StartCoroutine method of the GameManager, so lua coroutines can be executed locally to the script context.
BranchCoroutine Starts a new coroutine to run parallel to the current execution.
JoinCoroutines Waits for all specified coroutines to finish before continuing execution.

UI

Main article: UI (functions)

Textbox

Function Description
WaitShowDialogue Displays a dialogue box with text, waiting until the player completes it.
WaitShowTimedDialogue Displays a dialogue box with text, waiting until the specified time has expired.
TextDialogue Sets the current dialogue text to be shown. Requires WaitDialog to actually display.
WaitShowVoiceOver Displays a voice over, waiting until the player completes it.
TextVoiceOver Sets the current voice-over text to be shown. Requires WaitDialog to actually display.
TextPopUp Makes text pop up in the bottom-left corner by default.
WaitShowTitle Fades in a title text, waiting until the fade-in is complete.
TextShowTitle Shows text in the format of a title drop. Requires WaitDialog to actually display.
WaitHideTitle Fades out the currently displayed title, waiting until the fade-out is complete.
TextFadeTitle Fades out the text set in a title drop. Requires WaitDialog to actually fade.
WaitDialog Displays the currently set dialogue box and waits for the player to complete it.
_DummyWait Instantly break. Used as default/invalid value when returning a yieldable value.

Textbox Settings

Function Description
SetBounds Sets the position and size of the dialogue box.
ResetBounds Resets the position and size of the dialogue box.
SetCenter Sets the centering of the text in the textbox.
SetAutoFinish Makes the text automatically finish when it shows up.

Background

Function Description
WaitShowBG Fades in a chosen background image, with a chosen framerate, at a certain fade time, waiting until the fade-in is complete.
ShowBG Sets an image to display. Requires WaitDialog to actually display.
WaitHideBG Fades out the current background image, waiting until the fade-out is complete.
FadeBG Prepares a fade-out of the current image. Requires WaitDialog to actually display.

Speakers

Function Description
ResetSpeaker Clears the current speaker, so none is displayed the next time TextDialogue is called.
SetSpeaker Sets the speaker to be displayed during the following calls to the TextDialogue functions. It resets speaker emotion.
SetSpeakerReverse Reverses the speaker orientation to face left instead of right. This depends on the boolean passed in.

Speaker Settings

Function Description
SetSe Sets the speaker sound effect and speak frames played in the TextDialogue functions.
SetSpeakTime Sets the speak frames played in the TextDialogue functions.
ResetSe Resets to the default speaker sound effect and speaker frames.
SetSpeakerLoc Sets the position of the speaker in a dialogue box.
ResetSpeakerLoc Resets the position of the speaker in a dialogue box.
SetSpeakerEmotion Sets the emotion of the speaker in the dialogue box.

Choice Menu

Function Description
SetChoiceLoc Sets the position of the choices for a question dialog.
ResetChoiceLoc Sets the position of the choices for a question dialog back to default.
ChoiceMenuYesNo Ask a question answered by yes or no via character dialogue to the player.
BeginChoiceMenu Marks the start of a multi-choice menu.
BeginMultiPageMenu Marks the start of a multi-paged choice menu.
ChoiceResult Get the result of the last choice menu
GetChoiceAction (undocumented)
WaitForChoice Displays the currently set choice menu and waits for the player's selection to complete.
__WaitForChoice Wait for choice and then CLEAN UP m_curchoice

Functional Menus

Function Description
NameMenu Displays the name input box.
AssemblyMenu Displays a menu for replacing party members with the assembly.
ShopMenu Displays the Shop menu.
SellMenu Displays the Sell menu.
StorageMenu Displays the Storage menu for which to exchange items in the inventory with.
WithdrawMenu Displays the Storage menu for which to withdraw from.
BankMenu Displays the Bank menu.
SpoilsMenu Displays the Spoils menu.
AppraiseMenu Displays the Appraisal menu.
TutorTeamMenu Displays the Tutor Team menu.
RelearnMenu Displays the Relearn menu for a character.
LearnMenu Displays the Learn menu for a character to replace an existing skill with a new one.
ForgetMenu Displays the Forget menu for a character to forget a skill.
ShowPromoteMenu Displays the Promote menu to choose a team member to promote.
CanSwapMenu (Undocumented)
SwapMenu (Undocumented)
TributeMenu (Undocumented)
ShowMusicMenu Displays the Music menu to browse music for the game.
DungeonChoice Ask to enter a destintion via character dialogue to the player.
DestinationMenu Marks the start of a choice menu for choosing destinations, showing a preview of restrictions and requirements for dungeons.
ChooseMonsterMenu Marks the start of a choice menu for choosing monsters, showing a preview of their appearances via portrait.

Rescue Menus

Function Description
ServersMenu undocumented
ContactsMenu undocumented
SOSMenu undocumented
AOKMenu undocumented
PeersMenu undocumented
ShowConnectMenu undocumented

Custom Menus

Function Description
SetCustomMenu Displays a custom menu of the caller's choice.
BeginMultiPageMenu Marks the start of a multi-paged choice menu.