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:
| Folder | The Lua machine is used for | Details |
|---|---|---|
Data\LuaAPI | In-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_Ui | The server side of the UI windows drawn by the client (.ozg files made with EDITOR). | Lua UI |
Data\Scripts\Skills | Damage formulas and skill power per class. | Lua Skill |
Data\Scripts\Character | Character stat formulas and basic damage. | Section Data\Scripts below |
.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 / folder | Purpose | Read by | Reload | Usually edited |
|---|---|---|---|---|
LuaAPI.ini | Limits 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. | GameServer | Button Reload LuaAPI or Reload Lua UI | Change only if you understand it well; the defaults have been tested with thousands of players. |
LuaAPI.url | An Internet shortcut that opens the LuaAPI documentation page. Not a configuration file. | No program reads it | Not applicable | No. |
Main.lua | Entry point: loads System, then enables / disables each Includes module. | GameServer | Button Reload LuaAPI | Enable / disable modules with the LoadModule lines. |
System\Constants.lua | Shared constants: connection states, class codes... | GameServer | Button Reload LuaAPI (loaded through Main.lua) | Do not edit. |
System\FileReader.lua | Reads configuration files (Reader format) for the modules. | GameServer | Button Reload LuaAPI (loaded through Main.lua) | Do not edit. |
System\Modules.lua | The 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.*... | GameServer | Button Reload LuaAPI (loaded through Main.lua) | Do not edit. |
System\Callbacks.lua | The game event functions that GameServer calls (login, monster death, item pickup...). You can write your own code below the BridgeFunction_... lines. | GameServer | Button Reload LuaAPI | Only add your own code at the place marked in the file. |
System\CallbacksDB.lua | Receives database query results (DB.Query / DB.Execute) returned to the main thread. | GameServer | Button Reload LuaAPI | Do not edit. |
System\Timers.lua | Timers: onTimerProcessSecond every second, every minute, every hour, day change; repeating functions. | GameServer | Button Reload LuaAPI | Do not edit. |
System\Library.lua | A function library written in Lua on top of the GameServer API: item codes, colors, money by type, random level, action ticks, run schedules... | GameServer | Button 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). | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Use 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit 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. | GameServer | Button Reload LuaAPI | Edit in Config.lua: conditions for opening the warehouse. |
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 / folder | Purpose | Read by | Reload |
|---|---|---|---|
Main.lua | Entry 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.lua | Functions for working with client windows: UI.OnMessage (receives commands from the client), UI.Send, UI.Open... | GameServer | Button Reload Lua UI |
System\Constants.lua, Callbacks.lua, CallbacksDB.lua, Modules.lua, Timers.lua | The system part of Lua UI (constants, events, database results, modules, timers), in the same mold as LuaAPI. Do not edit. | GameServer | Button 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). | GameServer | Button Reload Lua UI (edit the configuration in Config.lua) |
Includes\Exchangegems\ | A window that exchanges equipment for a Jewel of Bless (F10 key). | GameServer | Button 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. | GameServer | Button Reload Lua UI |
Guide to writing windows: see Lua UI.
Data\Scripts
| File / folder | Purpose | Read by | Reload | Usually edited |
|---|---|---|---|---|
Character\CalcCharacter.lua | Character 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.lua | The 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. | GameServer | Runs at startup and on .reload item (button Reload items / Lua) | Adding a new item bag. |
Skills\*.lua, Skills\SkillLuaAPI.txt | Skill formulas per class (Common.lua and 16 class files) and the function documentation for skill scripts. | GameServer | .reload skill | See Map: Skills and Lua Skill. |
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.