This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getValue(x) | |
local flipped = 0 | |
if x % 10 > 5 then | |
flipped = 1 | |
end | |
local f | |
if (x + flipped) % 2 == 1 then | |
f = math.floor | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local matrixFields = { | |
area = {} | |
} | |
local Matrix = setmetatable(matrixFields, | |
{ | |
__call = function(matrix, ...) | |
return matrix.new(...) | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local defaults = { | |
name = "", | |
words = "", | |
mana = 0, | |
manaPercent = 0, | |
soul = 0, | |
spellId = 0, | |
range = -1, | |
level = 0, | |
magLevel = 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Class = setmetatable ({ }, | |
{ | |
__call = function (class, ...) | |
return class.new (...) | |
end | |
} | |
) | |
Class.__index = Class | |
Class.__call = function (self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- creates a full copy of a table | |
-- changing the value of copied table doesn't touch the original anymore | |
-- warning: using methods on "copied" userdata will still affect original object | |
local a = { | |
["abc"] = {1, 2}, | |
[1] = {4, {2}} | |
} | |
function cloneTable(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- who is showing changes and who is watching | |
spectated = Player("player") | |
spectator = Player("Administrator") | |
-- animated text, otclient only (or old clients) | |
-------------------------------- | |
msg = NetworkMessage() | |
msg:addByte(0x84) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
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 | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project.exe test.txt | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |