Skip to content

Instantly share code, notes, and snippets.

local vocTable = {
__add = function (t1, t2)
local ret = {}
for i, v in ipairs(t1) do
table.insert(ret, v)
end
for i, v in ipairs(t2) do
table.insert(ret, v)
end
return ret
function Player.getTotalSavedKills(self)
local Info = db.storeQuery("SELECT `frags` FROM `players` WHERE `id` = " .. self:getGuid())
local frags = result.getDataInt(Info, 'frags')
result.free(Info)
return frags
end
function Player.getTotalSavedDeaths(self)
local Info = db.storeQuery("SELECT `deaths` FROM `players` WHERE `id` = " .. self:getGuid())
local deaths = result.getDataInt(Info, 'deaths')
local spellsFile = io.open("data/test/spells.xml", "r")
local spellsFolder = "data/test/scripts/"
local convertsFolder = "data/test/converts/"
local instantSpells = {}
local function tobool(v)
return v and ( (type(v)=="number") and (v==1) or ( (type(v)=="string") and (v=="true") ) )
end
local function cleanSpaces(s)
MonsterLimits = {}
Global_Monster_Limit = 3
local startup = CreatureEvent("MonsterLimitStartup")
function startup.onLogin(player)
local guid = player:getGuid()
if not MonsterLimits[guid] then
MonsterLimits[guid] = {}
player:registerEvent("MonsterKillCounter")
@Codinablack
Codinablack / getOS.lua
Created January 19, 2022 19:04 — forked from Zbizu/getOS.lua
operating system (OS) detection in Lua
function getOS()
-- ask LuaJIT first
if jit then
return jit.os
end
-- Unix, Linux variants
local fh,err = assert(io.popen("uname -o 2>/dev/null","r"))
if fh then
osname = fh:read()
@Codinablack
Codinablack / loopEvent.lua
Created January 19, 2022 19:04 — forked from Zbizu/loopEvent.lua
reload safe addEvent loop example
-- configuration
LOOP_EVENT_DELAY = 5 * 1000 -- (in milliseconds)
-- register list of affected creatures and protect them from reload
if not LOOP_EVENT_REGISTERED_CREATURES then
LOOP_EVENT_REGISTERED_CREATURES = {}
end
-- store session id to reload the loop without duplicating it
if LOOP_EVENT_SESSION_ID then
@Codinablack
Codinablack / getVariables.lua
Created January 19, 2022 19:04 — forked from Zbizu/getVariables.lua
get all Lua functions (and globals)
-- usage: just call it in a Lua environment and look for a file called out.txt
-- lists all global variables in a file
function writeAllGlobals()
local file = io.open("out.txt", "w+")
local seen={}
local function dump(t,i)
seen[t]=true
local s={}
@Codinablack
Codinablack / magic_wall_rune.lua
Created January 19, 2022 19:04 — forked from Zbizu/magic_wall_rune.lua
Timer on magic wall rune (server side)
-- replace your mw script with this
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)
local function tile_timer(id, pos, delay, color)
if not Tile(pos):getItemById(id) then
return true
end
@Codinablack
Codinablack / asyncArea.lua
Created January 19, 2022 19:03 — forked from Zbizu/asyncArea.lua
non-blocking iteration over large areas
-- async iterate area
-- for when you want to execute a script on a large area, but dont want lags on your server
local defaultChunkSize = 16
local defaultDelay = 200
Area = setmetatable ({ },
{
__call = function (area, ...)
return area.new (...)
end
@Codinablack
Codinablack / launcher.bat
Created January 19, 2022 19:03 — forked from Zbizu/launcher.bat
replacer test
project.exe test.txt
pause