Lua Playground¶ Example: Script with bugs (3 errors) Example: Clean script (no errors) ▶ Test Clear Reset -- Login reward system with daily bonus local LOGIN_REWARDS = { { minReset = 0, item = GET_ITEM(14, 13), name = "Jewel of Bless" }, { minReset = 5, item = GET_ITEM(14, 14), name = "Jewel of Soul" }, { minReset = 10, item = GET_ITEM(14, 22), name = "Jewel of Creation" }, } BridgeFunctionAttach("OnCharacterEntry", function(aIndex) local player = GetUser(aIndex) if not player then return end GCNoticeSend(aIndex, 1, "Welcome, " .. player.Name .. "!") for _, reward in ipairs(LOGIN_REWARDS) do if player.Reset >= reward.minReset then ItemGive(aIndex, reward.item) LogAdd(LOG_GREEN, "[Reward] " .. player.Name .. " received " .. reward.name) end end end) -- Boss kill announcement + loot BridgeFunctionAttach("OnMonsterDie", function(aIndex, bIndex) local mob = GetUser(aIndex) local killer = GetUser(bIndex) if not mob or not killer then return end if gObjIsBossMonster(aIndex) then GCNoticeSendToAll(0, killer.Name .. " defeated a boss!") -- BUG: wrong arg count (4 instead of 5) ItemDrop(bIndex, killer.Map, killer.X, killer.Y) -- BUG: wrong arg count (3 instead of 4) gObjTeleport(bIndex, 0, 130) end end) -- Custom command: /zen BridgeFunctionAttach("OnCommandManager", function(aIndex, code, arg) if code ~= 100 then return 1 end local amount = tonumber(arg) or 0 if amount <= 0 then GCNoticeSend(aIndex, 1, "Usage: /zen ") return 0 end -- BUG: wrong arg count (1 instead of 2) gObjCharacterAddZen(aIndex) GCNoticeSend(aIndex, 1, "Added " .. amount .. " zen") return 0 end) -- Timer: periodic check BridgeFunctionAttach("OnTimerThread", function() for i = OBJECT_START_USER(), OBJECT_START_USER() + 10 do if gObjIsConnected(i) then local p = GetUser(i) if p and p.Life < p.MaxLife * 0.2 then GCNoticeSend(i, 1, "Low HP!") end end end end) LogAdd(LOG_BLUE, "Script loaded OK") Output Help