• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua TFS 1.4 OnStepIn

lordlazarus

New Member
Joined
Mar 28, 2016
Messages
12
Reaction score
0
Hi guys,

I need help on how I would make a function out of "onstepIn" to call the position of the effect. I know that inside the function would be easier, but would you be able to do it outside?

I think it would be something along those lines

local function itempos(item)
local pos = item:getPosition()
return true
end

function onStepIn(creature, item, position, fromPosition)
addEvent(itempos, 5000, creature.uid)
return true
end
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,772
Solutions
18
Reaction score
504
Location
Poland
Damn boiiiiii , why you passing creature.uid inside the arguments of function itempos which is related to item?!
What the HELLL is goin on here 🤔

Here, quick example
Lua:
function itemEffect(receivedItemObject)
    if not receivedItemObject then return false end

    local item = Item(receivedItemObject.uid)
    if not item then return false end

    local pos = item:getPosition()
    pos:sendMagicEffect(5)
    return true
end

function onStepIn(creature, item, position, fromPosition)
    -- addEvent arguments MUST be in following order : addEvent(function, time in miliseconds, other arguments that are used by function inside addEvent)
    addEvent(itemEffect, 5000, item)
    return true
end
 
Last edited:
OP
OP
L

lordlazarus

New Member
Joined
Mar 28, 2016
Messages
12
Reaction score
0
Post automatically merged:

Damn boiiiiii , why you passing creature.uid inside the arguments of function itempos which is related to item?!
I don't know where my head was. Did this example work for you? Here nothing happens when I step on the item.

If i remove that part

if not receivedItemObject then return false end and
if not item then return false end

this error appears, so for some reason it is not recognizing the item that I step on in the function

attempt to index local 'item' (a nil value)
stack traceback:
[C]: in function '__index'
 
Last edited:

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,772
Solutions
18
Reaction score
504
Location
Poland
Edited, try now.
Also, are you have any item on Tile where u stepping?
Depends on what you want to do, if you don't have any item on that Tile it obviously won't work :p
I just showed you an example how to "safety" pass an object into function that will be executed after time (in your case 5 seconds (5000))

 
Last edited:
OP
OP
L

lordlazarus

New Member
Joined
Mar 28, 2016
Messages
12
Reaction score
0
I have an item that when I step over it activates this example code you mentioned. But when I replaced this error appeared.

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/riftdemoniolv10.lua:onStepIn
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/movements/scripts/riftdemoniolv10.lua:133: in function <data/movements/scripts/riftdemoniolv10.lua:129>

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/movements/scripts/riftdemoniolv10.lua:37: attempt to index local 'receivedItemObject' (a number value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/riftdemoniolv10.lua:37: in function <data/movements/scripts/riftdemoniolv10.lua:34>
 
Top