• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua tfs 1.x script edit

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
LUA:
function onAddItem(item, tileitem, position)
    if Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        Game.sendMagicEffect({x = 32509, y = 31589, z = 15}, 13)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y = 31585, z = 15},3034)
        end
    end


how to modify this script part effect ---> Game.sendMagicEffect({x = 32509, y = 31589, z = 15}, 13)
to this effect appear during 3 minutes without stop with a delay of 2 seconds each effect?
 
Last edited:
Solution
This code should do what you described. You didn't really specify the conditions and you will most likely run into some problems like the effect being stacked multiple times etc.

LUA:
local effectDuration = 3*60
local effectInterval = 2

local function repeatEffect(pos, effect, repeats)
    Game.sendMagicEffect(pos, effect)
    if repeats > 0 then
        addEvent(repeatEffect, effectInterval*1000, pos, effect, repeats-1)
    end
end

function onAddItem(item, tileitem, position)
    if Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        repeatEffect({x = 32509, y = 31589, z = 15}, 13, effectDuration/effectInterval)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y =...
This code should do what you described. You didn't really specify the conditions and you will most likely run into some problems like the effect being stacked multiple times etc.

LUA:
local effectDuration = 3*60
local effectInterval = 2

local function repeatEffect(pos, effect, repeats)
    Game.sendMagicEffect(pos, effect)
    if repeats > 0 then
        addEvent(repeatEffect, effectInterval*1000, pos, effect, repeats-1)
    end
end

function onAddItem(item, tileitem, position)
    if Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        repeatEffect({x = 32509, y = 31589, z = 15}, 13, effectDuration/effectInterval)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y = 31585, z = 15},3034)
        end
    end
 
Solution
This code should do what you described. You didn't really specify the conditions and you will most likely run into some problems like the effect being stacked multiple times etc.

LUA:
local effectDuration = 3*60
local effectInterval = 2

local function repeatEffect(pos, effect, repeats)
    Game.sendMagicEffect(pos, effect)
    if repeats > 0 then
        addEvent(repeatEffect, effectInterval*1000, pos, effect, repeats-1)
    end
end

function onAddItem(item, tileitem, position)
    if Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        repeatEffect({x = 32509, y = 31589, z = 15}, 13, effectDuration/effectInterval)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y = 31585, z = 15},3034)
        end
    end

I will test, thanks so much!
Maybe the problem with effect being stacked multiple times etc.
Can be resolved with the script work only 1x per day.
 
worked, how to do this script work only one time per day? anyone know?
This code should do what you described. You didn't really specify the conditions and you will most likely run into some problems like the effect being stacked multiple times etc.

LUA:
local effectDuration = 3*60
local effectInterval = 2

local function repeatEffect(pos, effect, repeats)
    Game.sendMagicEffect(pos, effect)
    if repeats > 0 then
        addEvent(repeatEffect, effectInterval*1000, pos, effect, repeats-1)
    end
end

function onAddItem(item, tileitem, position)
    if Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        repeatEffect({x = 32509, y = 31589, z = 15}, 13, effectDuration/effectInterval)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y = 31585, z = 15},3034)
        end
    end
 
Try this? It will only work once per server restart not a day though.

LUA:
local effectDuration = 3*60
local effectInterval = 2
if not alreadyExecuted then
    alreadyExecuted = 0
end

local function repeatEffect(pos, effect, repeats)
    Game.sendMagicEffect(pos, effect)
    if repeats > 0 then
        addEvent(repeatEffect, effectInterval*1000, pos, effect, repeats-1)
    end
end

function onAddItem(item, tileitem, position)
    if alreadyExecuted == 0 and Game.isItemThere({x = 32511, y = 31585, z = 15},3034) then
        repeatEffect({x = 32509, y = 31589, z = 15}, 13, effectDuration/effectInterval)
        Game.sendMagicEffect({x = 32511, y = 31585, z = 15}, 16)
        Game.removeItemOnMap({x = 32511, y = 31585, z = 15},3034)
        alreadyExecuted = 1
        end
    end
 
Last edited:
Back
Top