Skip to content

LuaAPI Modules

itvnnnd87 edited this page Oct 24, 2026 · 3 revisions

Modules

A module is a script in Includes\<Module>\ that attaches its own functions to game events. Every attached function runs isolated: if one module fails, the error is logged (the first 5 times per function) and every other module still runs.

Attaching to an event

function MyModule_OnLogin(aIndex)
    Message.Send(aIndex, 1, "Hello " .. Player.GetName(aIndex))
end

BridgeFunctionAttach("OnCharacterEntry", "MyModule_OnLogin")

Pass the function name as a string. Attaching the same function twice to one event has no effect. An unknown event name is written to the log.

Module event Fired by Arguments Return value
OnReadScript onGameServerStart
OnShutScript onScriptUnload
OnTimerThread onTimerProcessSecond
OnCommandManager onLuaCommand aIndex, cmdtype, code, arg 0 = not mine, anything else = handled (the next modules are skipped).
OnCharacterEntry onPlayerLogin aIndex
OnCharacterClose onPlayerLogout aIndex
OnUserDie onPlayerDie aIndex, killerIndex
OnSQLAsyncResult onDBQueryResult label, param, result 1 = result taken (stop), 2 = run the query again, anything else = pass to the next module.
OnScheduleNotice, OnScheduleStart, OnScheduleEnd Scheduler eventType (+ secondsLeft)
On + any game event that event as the event Check events: false / 0 blocks the action and skips the next modules.

cmdtype is always 16 (the Type of LuaCommands.xml).

If you write your own global event function (for example onItemDrop) and modules attach to the same event, call BridgeDispatch("onItemDrop", ...) inside your function so the modules still run, and use its result for check events.

Short function names

Every module can also use these short names. Each one calls the matching function of the reference pages. Differences from the reference functions:

  • Checks return 1 / 0 instead of true / false (IsItem, EffectCheck, PermissionCheck, InventoryCheckSpaceByItem ...).
  • Item tables have both field name sets: Skill / Option1, Luck / Option2, Option / Option3, Exc / NewOption, Ancient / SetOption, Harmony / JoHOption, Option380 / 380Option, Sockets[1..5] / SocketOption1..5, SocketBonus / SocketOptionBonus, ExpireDate / DurationTime.
  • PartyGetMemberIndex(party, slot): slot starts at 0.
  • GetObjectGensFamily: 1 Vanert, 2 Duprian (the opposite of Player.GetGensFamily).
  • EffectAdd(aIndex, mode, effect, time): mode 1 = time is an expiry timestamp, otherwise seconds.
Group Functions
Server / objects GetGameServerCode GetGameServerVersion GetGameServerLang GetGameServerProtocol GetGameServerCurUser GetGameServerMaxUser GetMaxIndex GetMinUserIndex GetMaxUserIndex GetMinMonsterIndex GetMaxMonsterIndex GetObjectConnected GetObjectType GetObjectName GetObjectClass GetObjectMap GetObjectMapX GetObjectMapY GetObjectLive GetObjectIndexByName GetMapName MapCheckAttr Is28Option
Character - account GetObjectAccount GetObjectAccountID GetObjectAccountLevel GetObjectAccountExpireDate GetObjectPlayerID GetObjectAuthority GetObjectIpAddress GetObjectHardwareId GetPlayerMac GetPlayerSerial GetObjectOfflineFlag GetObjectLang UserSetAccountLevel CommandCheckGameMasterLevel
Character - levels GetObjectLevel GetObjectMasterLevel GetObjectMajesticLevel GetObjectToTalLevel GetObjectChangeUp GetObjectLevelUpPoint GetObjectMasterPoint GetObjectMajesticPoint GetObjectReset GetObjectMasterReset GetObjectLastGainedExp SetObjectLevel SetObjectMasterLevel SetObjectMajesticLevel SetObjectLevelUpPoint SetObjectMasterPoint SetObjectMajesticPoint SetObjectReset ChangeObjectReset
Character - stats GetObjectStrength GetObjectDexterity GetObjectVitality GetObjectEnergy GetObjectLeadership GetObjectTotal... GetObjectExtra... GetObjectDefault... (Strength / Dexterity / Vitality / Energy / Leadership) SetObjectStrength SetObjectDexterity SetObjectVitality SetObjectEnergy SetObjectLeadership
Character - HP / MP GetObjectLife GetObjectMaxLife GetObjectMana GetObjectMaxMana GetObjectBP GetObjectMaxBP GetObjectShield GetObjectMaxShield SetObjectLife SetObjectMaxLife SetObjectMana SetObjectMaxMana SetObjectBP SetObjectMaxBP SetObjectShield SetObjectMaxShield SetObjectLive (0 = kill)
Character - other GetObjectMoney SetObjectMoney GetObjectRuud SetObjectRuud RuudSend GetObjectPKCount GetObjectPKLevel GetObjectPKTimer SetObjectPKCount SetObjectPKLevel SetObjectPKTimer PKLevelSend GetObjectChange SkinChangeSend GetObjectInterface GetObjectCSGuildSide GetObjectDeathMap GetObjectDeathMapX GetObjectDeathMapY SetObjectChatLimitTime QuestStateCheck UserGetOptionTable UserSetOptionTable
Party / guild / gens GetObjectPartyNumber PartyGetMemberCount PartyGetMemberIndex GetObjectGuildNumber GetObjectGuildStatus GetObjectGuildName GetObjectGuildRelationship GetObjectGuildUnionNumber GetObjectGuildUnionName GetObjectGensFamily GetObjectGensRank GetObjectGensSymbol GetObjectGensContribution
Client updates / actions UserCalcAttribute CalculateCharacter UserInfoSend LevelUpSend MasterLevelUpSend UpdatePlayerLevels MoneySend CommandSend UserActionSend FireworksSend UserDisconnect UserGameLogout MoveUser MoveUserEx SetObjectMap SetObjectMapX SetObjectMapY UserWarehouseOpen MasterSkillTreeRebuild ResetMajesticTree SetWindowText
Permissions PermissionCheck PermissionInsert (allow) PermissionRemove (block). Numbers: 1 move item, 2 sell to NPC, 3 buy from NPC, 4 use item, 5 drop, 6 pick up, 7 trade, 8 open personal store, 10 cash shop, 11 chat, 12 teleport.
Coins CashShopGetPoint CashShopAddPoint CashShopSubPoint ObjectGetCoin (3 values) ObjectAddCoin ObjectSubCoin
Messages NoticeSend NoticeSendToAll NoticeGlobalSend MessageSend MessageSendToAll ChatTargetSend PostSend MessageGet
Inventory InventoryGetWearSize InventoryGetMainSize InventoryGetFullSize InventoryGetItemTable InventorySetItemTable InventoryGetItemIndex InventoryGetItemCount InventoryDelItemIndex InventoryDelItemCount InventoryGetFreeSlotCount InventoryCheckSpaceByItem InventoryCheckSpaceBySize
Event / Muun inventory EventInventoryGetFullSize EventInventoryGetItemTable EventInventoryGetItemIndex EventInventoryGetItemCount MuunInventoryGetWearSize MuunInventoryGetFullSize MuunInventoryGetItemTable MuunInventoryGetItemIndex MuunInventoryGetItemCount MuunInventoryDelItemIndex
Items ItemGive ItemDrop ItemGiveEx ItemDropEx CreateItem InsertItem_GremoryCase InsertItem_GremoryCaseEx GCTotalFreeSlotCount MapGetItemTable IsItem IsSocketItem IsElementalItem IsPentagramItem GetItemKindA GetBagItemLevel GetAncientOpt
Monsters / effects MonsterCreate MonsterCreateEx MonsterDelete MonsterSummonCreate MonsterSummonDelete EffectAdd EffectDel EffectCheck EffectClear
Config / other ConfigReadNumber ReadConfigNumber ConfigReadString ConfigSaveString LogColor LogPrint RandomGetNumber GetRandomValue CommandGetArgNumber CommandGetArgString SQLAsyncQuery

Argument order of the long item functions:

ItemGive(aIndex, bag)                       -- random item bag (GUID or name)
ItemDrop(aIndex, map, x, y, bag)
ItemGiveEx(aIndex, item, level, dur, skill, luck, option, exc, ancient, harmony, opt380,
           s1, s2, s3, s4, s5, socketBonus, duration)
ItemDropEx(aIndex, map, x, y, item, level, dur, skill, luck, option, exc, ancient, harmony, opt380,
           s1, s2, s3, s4, s5, socketBonus, duration)
CreateItem(useType, aIndex, map, x, y, item, level, dur, skill, luck, option, lootIndex, ancient, duration,
           isSocket, isElemental, muunEvo, exc, masteryExe, s1, s2, s3, s4, s5, socketBonus, errtelRank, count)
           -- useType 0 = ground, 1 = inventory
InsertItem_GremoryCase(aIndex, storage, reward, item, level, dur, skill, luck, option, ancient,
           isSocket, isElemental, muunEvo, exc, masteryExe, s1, s2, s3, s4, s5, socketBonus, receiptDuration, duration, count)
InsertItem_GremoryCaseEx(aIndex, storage, reward, item, level, dur, skill, luck, option, ancient, opt380,
           harmony, exc, unused, s1, s2, s3, s4, s5, socketBonus, duration, count)

Names that are not available

These names exist so that old scripts load, but they do nothing useful on this server. Calling one logs ...() is not supported by LuaAPI; the error only stops the function that called it.

Name Reason
GetObjectPassword, GetObjectPersonalCode Account secrets are never given to scripts.
GetObjectMaxNormalPoints Not used by this version.
EventInventorySetItemTable, EventInventoryDelItemIndex, EventInventoryDelItemCount, MuunInventorySetItemTable, MuunInventoryDelItemCount Not available. Use MuunInventory.DeleteSlot.
AddItemBag Item bags are defined in ItemBag files; use Item.GiveBag / Item.DropBag.
PartyCreate, PartyDelete, PartyAddMember, PartyDelMember Parties are managed by the players.
SendRgbChat Not available.

Next: Ready-made modules

Clone this wiki locally