Skip to content

Custom Lua functions

Raytwo edited this page Aug 30, 2024 · 12 revisions

Improvements

The Log script command will now output its argument to the terminal (assuming you play on emulator with guest logs enabled).

Custom Functions

Cobalt adds support for these custom Lua functions.

CobaltNotice

Displays a notification at the top of the screen similar to when new activities are available, but does not require a MSBT entry

Argument

  • Message (string): message to display in the notification

Example

-- Display a notice with the message "Cobalt now supports custom Lua commands!"
CobaltNotice("Cobalt now supports custom Lua commands!")

ItemGainSilent

Adds an item in the inventory of a unit without displaying the popup (similar to FE Fates)

Arguments

  • PID (string): PID of the receiving unit. provide nil if you want to send to convoy instead.
  • IID (string): IID of the item to give

Example

-- Silently add the Lollichop to Alear's inventory
ItemGainSilent("PID_リュール", "IID_ロリポップ斧")
-- Silently add the Lollichop to the convoy
ItemGainSilent(nil, "IID_ロリポップ斧")

UnitSetJob

Sets the job of a unit without displaying the class change animation. Resets the level to 1

Arguments

  • PID (string): PID of the target unit
  • JID (string): JID of the job to set
  • WeaponMask (number, optional): Flags to add weapon proficiencies to the Unit after the job change

Example

-- Turns Clanne into a Mage Knight that's proficient with swords
UnitSetJob("PID_クラン", "JID_マージナイト", 2)

UnitSetLevel

Silently sets the level of the target unit, this change is cosmetic only and does not increase stats or unlock skills

Arguments

  • PID (string): PID of the target unit
  • Level (number): Level to assign to the unit

Example

-- Set Alear's level to 7
UnitSetLevel("PID_リュール", 7)

UnitLearnJobSkill

Provide the unit with the job skill for its currently equipped job, disregarding the unit's level

Argument

PID (string): PID of the target unit

Example

-- Alear will now learn their job skill regardless of their level
UnitLearnJobSkill("PID_リュール")

ItemGift

Opens a window listing all the items received as part of a reward

Argument(s):

  • reward_id (string): ID of the reward group to gift the player with.
  • message_id (string): MSBT label of the message to display in the window

Example:

-- Gift the rewards for wave 3 of the Season Pass.
ItemGift("Patch3特典", "")

MenuItemShopShow / MenuWeaponShopShow / MenuRefineShopShow

Opens the respective shop menu

Example:

-- Open the item shop menu
MenuItemShopShow()

HasPurchasedSeasonPass

Returns a boolean to check if the player owns the season pass

Example:

-- Check if the player has the purchased the Season Pass.
local result = HasPurchasedSeasonPass()

if result == true then
    Log("Owns season pass")
else
    Log("Does not own season pass")
end

AddBondRing

Adds a Bond Ring to the player's rings

Argument(s):

  • RNID (string): ID of the bond ring to give to the player.
  • Count (number, optional): Amount of copies of the bond ring to give.

Example:

-- Add 69 copies of a bond ring to the player.
AddBondRing("RNID_Name_S", 69)
Clone this wiki locally