Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Zbizu / moduleManager.lua
Last active Nov 30, 2021
Lua module system concept
View moduleManager.lua
-- module system
if not Game.modules then
-- load
Game.modules = {
moduleList = {},
unLoadedModuleList = {}
}
else
-- reload
local newModuleList = {}
@Zbizu
Zbizu / chatchannels.xml
Last active Nov 27, 2021
Lua interpreter in chat channel
View chatchannels.xml
<channel id="32" name="Lua" script="luachannel.lua" />
@Zbizu
Zbizu / secretMenu.lua
Last active Nov 25, 2021
Special outfit window
View secretMenu.lua
-- works without adding anything to outfits.xml
local outfits = {
{12, "Archdemon"},
{75, "Gamemaster"},
{159, "Elf"},
{160, "Dwarf"},
{194, "Cultist"},
{226, "Frog"},
{253, "Headsplitter"},
{254, "Skullhunter"},
@Zbizu
Zbizu / screenshotLib.lua
Created Nov 22, 2021
Version 12 save screenshot
View screenshotLib.lua
SCREENSHOT_TYPE_ACHIEVEMENT = 1
SCREENSHOT_TYPE_BESTIARYENTRYCOMPLETED = 2
SCREENSHOT_TYPE_BESTIARYENTRYUNLOCKED = 3
SCREENSHOT_TYPE_BOSSDEFEATED = 4
SCREENSHOT_TYPE_DEATHPVE = 5
SCREENSHOT_TYPE_DEATHPVP = 6
SCREENSHOT_TYPE_LEVELUP = 7
SCREENSHOT_TYPE_PLAYERKILLASSIST = 8
SCREENSHOT_TYPE_PLAYERKILL = 9
SCREENSHOT_TYPE_PLAYERATTACKING = 10
@Zbizu
Zbizu / singleton.lua
Last active Nov 5, 2021
Lua singleton model
View singleton.lua
function CreateSingletonClass(self, obj)
obj.__index = obj
setmetatable(obj, self)
function obj.new(...)
if obj._instance then
return obj._instance
end
local instance = setmetatable({}, obj)
@Zbizu
Zbizu / clientid.lua
Created Oct 23, 2021
client id tester
View clientid.lua
-- client id tester
-- /lex clientId
-- installation: drop into data/scripts folder
local talk = TalkAction("/lex", "/looktypeex")
function talk.onSay(player, words, param)
if not player:getGroup():getAccess() then
return true
end
@Zbizu
Zbizu / msg.lua
Created Oct 20, 2021
Blue message version 12
View msg.lua
-- example replacement for lack of MESSAGE_STATUS_CONSOLE_BLUE:
player:sendPrivateMessage(nil, "Players online: Name [1], Other Name [41], Placeholder [10]")
-- output: 21:41 [0]: Players online: Name [1], Other Name [41], Placeholder [10]
-- hypothetically the function could be adjusted (source edit) to send "Players online" as player name and "level" as players online
@Zbizu
Zbizu / findFiles.lua
Last active Oct 18, 2021
Loop through all Lua files in a single directory
View findFiles.lua
if getOS():lower() == "windows" then
for path in io.popen("cd \"data\lib\" && dir *.lua /b/s"):lines() do
print(path) -- path = file name/directory
end
else
for path in io.popen("cd data/lib && find . -type f | grep .lua"):lines() do
print(path)
end
end
@Zbizu
Zbizu / preview.md
Last active Oct 17, 2021
protocol 12 icons test
@Zbizu
Zbizu / fileDir.lua
Created Sep 19, 2021
Get current script directory
View fileDir.lua
--[[
dumps file directory to a console
example output:
linedefined 0
lastlinedefined 207
source @F:\ot\data\scripts\filename.lua
what main
short_src ...ot\data\scripts\filename.lua
]]