Skip to content

LuaAPI Folder Structure

itvnnnd87 edited this page Oct 24, 2026 · 2 revisions

Folder structure and reloading

The Data\LuaAPI folder

Path Contents
Main.lua Entry point. The GameServer loads this file. Add your modules at the end.
System\Callbacks.lua Game events: login, logout, death, chat commands.
System\CallbacksDB.lua Database query results.
System\Timers.lua Per-second / minute / hour / day-change events and the Timer.* functions.
System\Modules.lua Module system: BridgeFunctionAttach and the short function names (Modules). Do not edit.
System\Constants.lua Constants (OBJECT_ONLINE, CLASS_*, MAP_*, STAT_*, POWER_*, ACTION_* ...).
System\Library.lua Ready-made Lua libraries: coins by type, scheduler, monster tracker, player object (Library). Do not edit.
System\FileReader.lua Line-by-line file reader (Reader:Load).
Includes\<Module>\... One folder per feature.

Adding a module

  1. Create the folder Includes\MyModule\ and the file Includes\MyModule\MyModule.lua.
  2. Add this line at the end of Main.lua:
LoadModule("MyModule\\MyModule")

A module that fails to load only breaks itself; every other module still loads.

require("A\\B") looks for LuaAPI\A\B.lua first, then LuaAPI\Includes\A\B.lua.

Loading and reloading

  • The GameServer loads the scripts on startup.
  • Reload without restarting: GameServer control panel (inside START) → Reload LuaAPI. This reloads Main.lua, every module and Data\Commands\LuaCommands.xml.
  • Reload order: onScriptUnload (old scripts) → load the new scripts → onGameServerStart → onPlayerLogin for every player already online.
  • A reload starts from zero: every function, event, module and file is loaded again, as on a fresh start. Nothing from the old scripts is kept:
    • Lua variables, timers, attached module functions, ActionTick, the scheduler state.
    • Events waiting to be delivered and database queries that have not returned yet are dropped.
    • Monster.WatchRespawn / Skill.Watch lists: call them again when your script loads.
    • Option tables (Player.SetOptionTable) and blocked actions (Player.BlockAction). The GameServer recalculates the stats of the characters that had an option table, so no old bonus stays. Set them again in onPlayerLogin.
    • Monsters registered in EventMonsterTracker are removed during onScriptUnload.
  • Saved data is not touched: characters, coins, items, buffs and the database stay as they are.
  • Script errors are written to the GameServer log with the file name and line number.

Next: Events and chat commands

Clone this wiki locally