Overview

GameServer runs several separate Lua machines, each reading its own folder (ItemBagScript.lua also runs on its own Lua machine). They do not share functions or variables, and an error in one machine does not affect the others:

FolderThe Lua machine is used forDetails
Data\LuaAPIIn-game events, chat commands, timers, database queries: the feature modules (welcome message, item exchange, top-up rewards...).Lua API; described in the section Data\LuaAPI below
Data\Lua_UiThe server side of the UI windows drawn by the client (.ozg files made with EDITOR).Lua UI
Data\Scripts\SkillsDamage formulas and skill power per class.Lua Skill
Data\Scripts\CharacterCharacter stat formulas and basic damage.Section Data\Scripts below
Reloading: the GameServer control panel has a separate button for each machine: Reload LuaAPI (Data\LuaAPI), Reload Lua UI (Data\Lua_Ui), Reload in the Skill tools or .reload skill (Scripts\Skills). Each machine reloads independently.

Data\LuaAPI

The entry point is Main.lua: it loads the system part in System, then loads each module in Includes with lines of the form LoadModule("Name\\Name"). A module whose line starts with -- is disabled; remove the -- to enable it. Currently enabled: WelcomeMessage, NpcMessage, CustomWindowName. A module with an error only breaks itself; the other modules keep running.

File / folderPurposeRead byReloadUsually edited
LuaAPI.iniLimits of the Lua machine so that a slow or faulty script cannot hang GameServer: maximum run time per call (Timeout, default 2000 ms), time allowed while loading Main.lua (LoadTimeout, default 10000 ms), memory (MemoryLimitMB, default 256), event queue, packet sending rate. The [LuaUi] section has Timeout (5000 ms) and MemoryLimitMB (128) for Lua UI. A missing key uses the default; a value outside the allowed range is moved to the nearest limit.GameServerButton Reload LuaAPI or Reload Lua UIChange only if you understand it well; the defaults have been tested with thousands of players.
LuaAPI.urlAn Internet shortcut that opens the LuaAPI documentation page. Not a configuration file.No program reads itNot applicableNo.
Main.luaEntry point: loads System, then enables / disables each Includes module.GameServerButton Reload LuaAPIEnable / disable modules with the LoadModule lines.
System\Constants.luaShared constants: connection states, class codes...GameServerButton Reload LuaAPI (loaded through Main.lua)Do not edit.
System\FileReader.luaReads configuration files (Reader format) for the modules.GameServerButton Reload LuaAPI (loaded through Main.lua)Do not edit.
System\Modules.luaThe module system: BridgeFunctionAttach attaches module functions to GameServer events; each function runs separately, so an error in one module does not block the others; short function names (GetObjectLevel, NoticeSend...) are linked to Player.*, Message.*...GameServerButton Reload LuaAPI (loaded through Main.lua)Do not edit.
System\Callbacks.luaThe game event functions that GameServer calls (login, monster death, item pickup...). You can write your own code below the BridgeFunction_... lines.GameServerButton Reload LuaAPIOnly add your own code at the place marked in the file.
System\CallbacksDB.luaReceives database query results (DB.Query / DB.Execute) returned to the main thread.GameServerButton Reload LuaAPIDo not edit.
System\Timers.luaTimers: onTimerProcessSecond every second, every minute, every hour, day change; repeating functions.GameServerButton Reload LuaAPIDo not edit.
System\Library.luaA function library written in Lua on top of the GameServer API: item codes, colors, money by type, random level, action ticks, run schedules...GameServerButton Reload LuaAPI (loaded through Main.lua)Do not edit.
Includes\WelcomeMessage\Sends one or more welcome messages to a character when it enters the game (variables: name, level, reset, VIP, map, number of players online; font size and color can be adjusted).GameServerButton Reload LuaAPIEdit in Config.lua: the welcome message content.
Includes\NpcMessage\NPCs speak periodically to nearby players; a monster that kills a player says a taunting line and can announce it to the whole server.GameServerButton Reload LuaAPIEdit in Config.lua: the NPC list and the lines.
Includes\CustomWindowName\Shows character information in the game window title (channel, name, top-up amount, reset, level, WCoin...), refreshed every few seconds.GameServerButton Reload LuaAPIEdit in Config.lua: the title template.
Includes\CmdCommands\An example chat command written in Lua (/test 5 hello). A starting point for writing your own commands; commands are declared in Data\Commands\LuaCommands.xml. Currently disabled in Main.lua.GameServerButton Reload LuaAPIUse as a template.
Includes\CustomItemExchange\Exchanges items for currency (WCoin, Goblin Point or Ruud) with chat commands (/bless 50, /exchange); the amount depends on the VIP level. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: the exchange price table.
Includes\CumulativeRecharge\Rewards by cumulative top-up tier: one-time rewards and daily / weekly / monthly rewards, through 2 NPCs. Has a .sql file that creates the tables. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: top-up tiers, rewards.
Includes\RechargeGift\An NPC gives gifts based on the total amount topped up; gifts are sent to the Gremory Case (K key). Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: top-up milestones, gifts.
Includes\DailyReward\Each account receives a random item bag once per day on login, the bag depending on the VIP level. Has a .sql file that creates the table. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: bags by VIP.
Includes\Entrylimit\Blocks players by IP address, IP prefix, MAC or disk serial number; a test-server mode lets only the accounts on a list enter. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: block / allow lists.
Includes\ItemOptionExpand\Gives the character bonus stats for each equipped item that reaches a set level (for example +13 adds damage, +15 adds more). The Config.lua file is very large. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: the bonus table per item.
Includes\MonsterSpawn\Keeps a fixed number of monsters at set points; killing a monster gives reward items; monsters are removed when LuaAPI is reloaded or the server is shut down. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: spawn points, quantity, rewards.
Includes\RandomQuestSystem\A timed event: talk to an NPC to draw a random monster-hunting quest with a time limit, rewarding WCoin, Goblin Point, Ruud. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: rates, rewards, times.
Includes\ShopPointRate\Special monsters give currency (WCoin, Goblin Point, Ruud) at a random rate; optionally normal monsters drop it too, and experience can be converted to Zen. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: monster list, rates.
Includes\Warehouse\Opens the warehouse anywhere with a command (/warehouse); can be restricted to VIP, cost Zen, or work only in safe zones. Currently disabled in Main.lua.GameServerButton Reload LuaAPIEdit in Config.lua: conditions for opening the warehouse.
Each module folder in Includes has 3 kinds of file: <Name>.lua (the script, do not edit), Config.lua (the configuration, the place to edit) and README.txt (its own guide). If a folder contains a .sql file, run it once on the game database to create the tables.

Data\Lua_Ui

The server side of the UI windows that the client draws (the <Name>.ozg and <Name>.lua files on the client, made with EDITOR). It is a separate Lua machine, independent of LuaAPI; errors and the Reload Lua UI command here do not affect LuaAPI. The server always decides and never trusts data sent up by the client. It only runs when the UiLua feature has been purchased and UiLua = 1 in the [Plugin] section of Data\Plugin\Plugin.ini (GameServer reads only this key; Common.ini has no UiLua key, and the comment line in the Main.lua of this folder that mentions Common.ini is an old comment).

File / folderPurposeRead byReload
Main.luaEntry point of Lua UI: loads System, then the windows in Includes (to add a window, add a folder plus one LoadModule line). Function names are taken from LuaAPI with the prefix Ui_ (for example Ui_Player.GetMoney).GameServer (LuaUi)Button Reload Lua UI
System\UI.luaFunctions for working with client windows: UI.OnMessage (receives commands from the client), UI.Send, UI.Open...GameServerButton Reload Lua UI
System\Constants.lua, Callbacks.lua, CallbacksDB.lua, Modules.lua, Timers.luaThe system part of Lua UI (constants, events, database results, modules, timers), in the same mold as LuaAPI. Do not edit.GameServerButton Reload Lua UI
Includes\demo1\A sample window: put an equipment item in the slot and press OK to receive a Jewel of Bless (like the Chaos Goblin window).GameServerButton Reload Lua UI (edit the configuration in Config.lua)
Includes\Exchangegems\A window that exchanges equipment for a Jewel of Bless (F10 key).GameServerButton Reload Lua UI (edit the configuration in Config.lua)
Includes\UiDemo\A server-side example for the client window named "Zu": a button sends the info command and the server returns the real character data.GameServerButton Reload Lua UI

Guide to writing windows: see Lua UI.

Data\Scripts

File / folderPurposeRead byReloadUsually edited
Character\CalcCharacter.luaCharacter stat formulas: physical and magic damage (<Class>DamageCalc, <Class>MagicDamageCalc), AG amount... per class (from Strength, Dexterity, Vitality, Energy). Other settings of this calculation are in Data\CalcCharacter.ini. Time limits apply: each time GameServer calls a function it may run for at most 200 ms, and loading the file may take at most 5 seconds; beyond that the function is stopped and logged, and GameServer does not hang.GameServer (CharacterBase).reload character (reloaded together with CharacterFormula.xml)Damage formulas per class.
Item\ItemBagScript.luaThe item bag list: each line attaches an ID of a file in Data\ItemBags (named like ID - Type - Name.xml) to a trigger (when the bag is opened). Other configuration files call the bag by ID. A file in ItemBags without a line here is not used. With a syntax error GameServer reports an error and loads no bag at all.GameServerRuns at startup and on .reload item (button Reload items / Lua)Adding a new item bag.
Skills\*.lua, Skills\SkillLuaAPI.txtSkill formulas per class (Common.lua and 16 class files) and the function documentation for skill scripts.GameServer.reload skillSee Map: Skills and Lua Skill.
Editing a Lua file with a syntax error: a broken CalcCharacter.lua can make all character stats wrong; a broken ItemBagScript.lua means no item bag is loaded. Always back up the file before editing and check the GameServer log after reloading.