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_* ...).
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.
  • Database queries of the old scripts that have not returned yet are dropped. Timers are cleared.
  • Script errors are written to the GameServer log with the file name and line number.

Next: Events and chat commands

Clone this wiki locally