Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Zbizu / magic_wall_rune.lua
Created July 22, 2021 21:31
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
@Zbizu
Zbizu / wild_growth_rune.lua
Created July 22, 2021 21:32
timer, wild growth version
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_WILDGROWTH)
local function tile_timer(id, pos, delay, color)
if not Tile(pos):getItemById(id) then
return true
end
if delay ~= 1 then
@Zbizu
Zbizu / animatedText.lua
Last active July 30, 2021 21:23
[TFS 1.3][8.6 downgrade only] doSendAnimatedText
-- just place this in libs
function doSendAnimatedText(pos, text, color, player)
local p = Player(player)
if not p then
return false
end
local msg = NetworkMessage()
msg:addByte(0x84)
msg:addPosition(pos)
@Zbizu
Zbizu / #__vscode_functions.lua
Last active August 18, 2021 23:36
Visual Studio Code globals for Lua scripting in TFS 1.3
-- what is it:
-- this is a file designed to make vs code's Lua extension intellisense working properly
-- it contains placeholders for Lua content defined by C++ files
-- how to use:
-- download vs code
-- install sumneko's lua extension
-- drop this file to your data/scripts folder
-- make sure it starts with # so it won't get loaded by the tfs
-- open folder in vs code
@Zbizu
Zbizu / asyncArea.lua
Created July 28, 2021 22:37
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
@Zbizu
Zbizu / launcher.bat
Last active January 19, 2022 19:03
replacer test
project.exe test.txt
pause
@Zbizu
Zbizu / fileDir.lua
Created September 19, 2021 16:56
Get current script directory
--[[
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
]]
@Zbizu
Zbizu / preview.md
Last active June 27, 2023 12:29
protocol 12 icons test

new_icon

@Zbizu
Zbizu / findFiles.lua
Last active May 26, 2023 21:55
Loop through all Lua files in a single directory
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 / msg.lua
Created October 20, 2021 19:46
Blue message version 12
-- 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