• 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!

TFS 1.X+ TFS 1.3 Movement, cant print the creature name

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,424
Solutions
15
Reaction score
177
Location
Sweden
I'm missing something probably very easy but my brain cant cooperate, someone that see's my flaw?
Using: TFS 1.3


The script itself:
Lua:
function onStepIn(player, item, position, fromPosition)
 if item:getActionId() == 10100 then
    local p = position
    local t = getTileThingByPos({x=p.x,y=p.y-1,z=p.z})
        print(t.name)
        print(p.x, p.y-1, p.z, p.stackpos)
 end
end
Proving its setup correct:
qwdqwd.png
"Error" in console: (it prints nil, i want the name):
nil
1040 1141 5 0
Printing t:getName() gives this error:
attempt to call method 'getName' (a nil value)
 
Solution
E
why not use
Lua:
t:getTopCreature():getName()
?

something like this:

Lua:
function onStepIn(player, item, position, fromPosition)
    if item:getActionId() == 10100 then
        local t = Tile(position)
        if t then
            print(t:getTopCreature():getName())
        end
    end
end
why not use
Lua:
t:getTopCreature():getName()
?

something like this:

Lua:
function onStepIn(player, item, position, fromPosition)
    if item:getActionId() == 10100 then
        local t = Tile(position)
        if t then
            print(t:getTopCreature():getName())
        end
    end
end
 
Solution
why not use
Lua:
t:getTopCreature():getName()
?

something like this:

Lua:
function onStepIn(player, item, position, fromPosition)
    if item:getActionId() == 10100 then
        local t = Tile(position)
        if t then
            print(t:getTopCreature():getName())
        end
    end
end
Tried that as well as my custom getThingFromPos, but it returns nil or the other error just.

Edit:
script: (reason i don't use plain position is that I want to check the creature that is above the players position)
Lua:
function onStepIn(player, item, position, fromPosition)

 if item:getActionId() == 10100 then
    local p = position
    local t = {x=p.x,y=p.y-1,z=p.z}
        if t then
            print(t:getTopCreature():getName())
        end
 end
end
Error:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/teleports/spawns.lua:eek:nStepIn
data/movements/scripts/teleports/spawns.lua:7: attempt to call method 'getTopCreature' (a nil value)
stack traceback:
[C]: in function 'getTopCreature'
data/movements/scripts/teleports/spawns.lua:7: in function <data/movements/scripts/teleports/spawns.lua:1>


Edit 2:
My bad, forgot to check Tile, here's the working result in case anyone from future wonders:
Lua:
function onStepIn(player, item, position, fromPosition)

 if item:getActionId() == 10100 then
    local p = position
    local t = Tile({x=p.x,y=p.y-1,z=p.z})
        if t then
            print(t:getTopCreature():getName())
        end
 end
end
 
Last edited:
Back
Top