Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Created July 22, 2021 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Zbizu/cca536d6c72dbef8afe2fccb695284ff to your computer and use it in GitHub Desktop.
Save Zbizu/cca536d6c72dbef8afe2fccb695284ff to your computer and use it in GitHub Desktop.
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
if delay ~= 1 then
addEvent(tile_timer, 1000, id, pos, delay - 1, color)
end
local people = Game.getSpectators(pos, 7, 7, 5, 5, false, true)
if not people then
return true
end
for i = 1, #people do
people[i]:sendTextMessage(MESSAGE_EXPERIENCE, "Magic wall will disappear in " .. delay .. " second" .. (delay > 1 and "s" or "") .. ".", pos, delay, color)
end
end
function onCastSpell(creature, variant, isHotkey)
local c = combat:execute(creature, variant)
if c then
tile_timer(ITEM_MAGICWALL, variantToPosition(variant), 20, TEXTCOLOR_LIGHTBLUE)
end
return c
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment