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

'getTile' (a nil value)

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
I'm getting this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/demon helmet.lua:onUse
data/actions/scripts/quests/demon helmet.lua:9: attempt to call method 'getTile' (a nil value)
stack traceback:
        [C]: in function 'getTile'
        data/actions/scripts/quests/demon helmet.lua:9: in function <data/actions/scripts/quests/demon helmet.lua:7>

i tried Tile(position) aswell, but didnt work obviously.
script.
Code:
local t = {
    Position(1222, 897, 10), -- stone position
    Position(1224, 896, 10), -- teleport creation position
    Position(1230, 914, 9) -- where the teleport takes you
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local tile = t[1]:getTile()
        if tile then
            local stone = tile:getItemById(1355)
            if stone then
                stone:remove()
            end
        end

        local teleport = Game.createItem(1387, 1, t[2])
        if teleport then
            teleport:setDestination(t[3])
            t[2]:sendMagicEffect(CONST_ME_TELEPORT)
        end
    elseif item.itemid == 1946 then
        local tile = t[2]:getTile()
        if tile then
            local teleport = tile:getItemById(1387)
            if teleport and teleport:isTeleport() then
                teleport:remove()
            end
        end
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1355, 1, t[1])
    end
    return item:transform(item.itemid == 1945 and 1946 or 1945)
end

Thanks in advance.
 
Solution
Try like this, let me know:

LUA:
local t = {
    [1] = {x=1222,y=897,z=10}, -- stone position
    [2] = {x=1224,y=896,z=10}, -- teleport creation position
    [3] = {x=1230,y=914,z=9} -- where the teleport takes you
}
that won't work since it's no longer a position object with methods, it's just a regular table
you need something like this in your position.lua in lib folder
LUA:
function Position.getTile(self)
    return Tile(self)
end
I'm getting this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/demon helmet.lua:onUse
data/actions/scripts/quests/demon helmet.lua:9: attempt to call method 'getTile' (a nil value)
stack traceback:
        [C]: in function 'getTile'
        data/actions/scripts/quests/demon helmet.lua:9: in function <data/actions/scripts/quests/demon helmet.lua:7>

i tried Tile(position) aswell, but didnt work obviously.
script.
Code:
local t = {
    Position(1222, 897, 10), -- stone position
    Position(1224, 896, 10), -- teleport creation position
    Position(1230, 914, 9) -- where the teleport takes you
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        local tile = t[1]:getTile()
        if tile then
            local stone = tile:getItemById(1355)
            if stone then
                stone:remove()
            end
        end

        local teleport = Game.createItem(1387, 1, t[2])
        if teleport then
            teleport:setDestination(t[3])
            t[2]:sendMagicEffect(CONST_ME_TELEPORT)
        end
    elseif item.itemid == 1946 then
        local tile = t[2]:getTile()
        if tile then
            local teleport = tile:getItemById(1387)
            if teleport and teleport:isTeleport() then
                teleport:remove()
            end
        end
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1355, 1, t[1])
    end
    return item:transform(item.itemid == 1945 and 1946 or 1945)
end

Thanks in advance.


Try like this, let me know:

LUA:
local t = {
    [1] = {x=1222,y=897,z=10}, -- stone position
    [2] = {x=1224,y=896,z=10}, -- teleport creation position
    [3] = {x=1230,y=914,z=9} -- where the teleport takes you
}
 
Try like this, let me know:

LUA:
local t = {
    [1] = {x=1222,y=897,z=10}, -- stone position
    [2] = {x=1224,y=896,z=10}, -- teleport creation position
    [3] = {x=1230,y=914,z=9} -- where the teleport takes you
}
that won't work since it's no longer a position object with methods, it's just a regular table
you need something like this in your position.lua in lib folder
LUA:
function Position.getTile(self)
    return Tile(self)
end
 
Solution

Similar threads

  • Question Question
Replies
1
Views
478
Back
Top