Skip to content

Instantly share code, notes, and snippets.

@Codinablack
Codinablack / ClassExample.lua
Created January 19, 2022 19:00 — forked from Zbizu/ClassExample.lua
lua "class" example
local Class = setmetatable ({ },
{
__call = function (class, ...)
return class.new (...)
end
}
)
Class.__index = Class
Class.__call = function (self)
@Codinablack
Codinablack / ClassWithAutoMethods.lua
Created January 19, 2022 19:00 — forked from Zbizu/ClassWithAutoMethods.lua
automated getter/setter generation example for lua "classes"
local defaults = {
name = "",
words = "",
mana = 0,
manaPercent = 0,
soul = 0,
spellId = 0,
range = -1,
level = 0,
magLevel = 0,
@Codinablack
Codinablack / matrix.lua
Created January 19, 2022 18:59 — forked from Zbizu/matrix.lua
matrix operations in lua
local matrixFields = {
area = {}
}
local Matrix = setmetatable(matrixFields,
{
__call = function(matrix, ...)
return matrix.new(...)
end
}
@Codinablack
Codinablack / lagLessSave.lua
Created January 19, 2022 18:59 — forked from Zbizu/lagLessSave.lua
less laggy player saving (tfs 1.3 or a fork that supports revscriptsys)
local noLagSave = GlobalEvent("noLagSave")
local timeBetweenSaves = 1 * 60 * 60 * 1000 -- in milliseconds
local delayBetweenSaves = 100
function delayedSave(cid)
local p = Player(cid)
if p then
p:save()
end
end