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

0.2.8 mystic spirit; error attempt to call global 'position' a nil value

cesar ramirez

New Member
Joined
Jul 26, 2018
Messages
3
Reaction score
0
Hello i had this error trying to make a script by myself modifing other ones

Code:
local pos = {
    altar1 = Position({x=581, y=189, z=8}),
    altar2 = Position({x=583, y=192, z=8}),
    altar3 = Position({x=582, y=193, z=8}),
    altar4 = Position({x=581, y=193, z=8}),
    altar5 = Position({x=580, y=193, z=8}),
    altar6 = Position({x=579, y=192, z=8}),
    altar7 = Position({x=589, y=194, z=8}),
    stand = Position({x = 581, y = 191, z = 8}),
    teleportTo = Position({x = 615, y = 212, z = 7})

}
function onUse(creature, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 and creature:isPlayer() then
        local topItem = Tile(pos.altar1):getTopVisibleThing(creature)
        if topItem.itemid == 2335 then
            local topItem = Tile(pos.altar2):getTopVisibleThing(creature)
        if topItem.itemid == 2336 then
            local topItem = Tile(pos.altar3):getTopVisibleThing(creature)
        if topItem.itemid == 2337 then
            local topItem = Tile(pos.altar4):getTopVisibleThing(creature)
        if topItem.itemid == 2338 then
            local topItem = Tile(pos.altar5):getTopVisibleThing(creature)
        if topItem.itemid == 2339 then
            local topItem = Tile(pos.altar6):getTopVisibleThing(creature)
        if topItem.itemid == 2340 then
            local topItem = Tile(pos.altar7):getTopVisibleThing(creature)
        if topItem.itemid == 2341 then
            if creature:getPosition():getDistance(pos.stand) == 0 then
                topItem:remove()
                creature:sendTextMessage(MESSAGE_INFO_DESCR, "You Assemble the Ancient Helmet")
                doPlayerAddItem(cid,2342,1)
                creature:teleportTo(pos.teleportTo)
            end
        end
    end
end
end
end
end
end

    end
    return true
end

What im trying to do its In the map are 7 altars were you need to put one piece of ancient helmet in each altar; when you use the leaver, it deletes the items and put in your bag the ancient helmet and teleporting you to the temple.
 
Solution
The topic is saying 0.2.8, but your script tells us something different :D
Try something like that
LUA:
local stand = {x = 581, y = 191, z = 8}
local teleportTo = {x = 615, y = 212, z = 7}

local altars =
{
    { ["pos"] = {x=581, y=189, z=8}, ["itemid"] = 2335 },
    { ["pos"] = {x=583, y=192, z=8}, ["itemid"] = 2336 },
    { ["pos"] = {x=582, y=193, z=8}, ["itemid"] = 2337 },
    { ["pos"] = {x=581, y=193, z=8}, ["itemid"] = 2338 },
    { ["pos"] = {x=580, y=193, z=8}, ["itemid"] = 2339 },
    { ["pos"] = {x=579, y=192, z=8}, ["itemid"] = 2340 },
    { ["pos"] = {x=589, y=194, z=8}, ["itemid"] = 2341 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 and isPlayer(cid) then
        if...
The topic is saying 0.2.8, but your script tells us something different :D
Try something like that
LUA:
local stand = {x = 581, y = 191, z = 8}
local teleportTo = {x = 615, y = 212, z = 7}

local altars =
{
    { ["pos"] = {x=581, y=189, z=8}, ["itemid"] = 2335 },
    { ["pos"] = {x=583, y=192, z=8}, ["itemid"] = 2336 },
    { ["pos"] = {x=582, y=193, z=8}, ["itemid"] = 2337 },
    { ["pos"] = {x=581, y=193, z=8}, ["itemid"] = 2338 },
    { ["pos"] = {x=580, y=193, z=8}, ["itemid"] = 2339 },
    { ["pos"] = {x=579, y=192, z=8}, ["itemid"] = 2340 },
    { ["pos"] = {x=589, y=194, z=8}, ["itemid"] = 2341 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 and isPlayer(cid) then
        if getDistanceBetween(getcidPosition(cid), stand) > 0 then
            -- not on a position
            return true
        end
     
        local items = {}
        for i = 1, #altars do
            local item = getTileItemById(altars[i].pos, altars[i].itemid)
            if(item == 0) then
                -- item not found
                return true
            end
            table.insert(items, item)
        end

        for i = 1, #items do doRemoveItem(items[i]) end
        doPlayerSendTextMessage(cid, 22, "You Assemble the Ancient Helmet")
        doPlayerAddItem(cid, 2342)
        doTeleportThing(cid, teleportTo)
    end
 
    return true
end
 
Last edited:
Solution
The topic is saying 0.2.8, but your script tells us something different :D
Try something like that
LUA:
local stand = {x = 581, y = 191, z = 8}
local teleportTo = {x = 615, y = 212, z = 7}

local altars =
{
    { ["pos"] = {x=581, y=189, z=8}, ["itemid"] = 2335 },
    { ["pos"] = {x=583, y=192, z=8}, ["itemid"] = 2336 },
    { ["pos"] = {x=582, y=193, z=8}, ["itemid"] = 2337 },
    { ["pos"] = {x=581, y=193, z=8}, ["itemid"] = 2338 },
    { ["pos"] = {x=580, y=193, z=8}, ["itemid"] = 2339 },
    { ["pos"] = {x=579, y=192, z=8}, ["itemid"] = 2340 },
    { ["pos"] = {x=589, y=194, z=8}, ["itemid"] = 2341 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 and isPlayer(cid) then
        if getDistanceBetween(getcidPosition(cid), stand) > 0 then
            -- not on a position
            return true
        end
    
        local items = {}
        for i = 1, #altars do
            local item = getTileItemById(altars[i].pos, altars[i].itemid)
            if(item == 0) then
                -- item not found
                return true
            end
            table.insert(items, item)
        end

        for i = 1, #items do doRemoveItem(items[i]) end
        doPlayerSendTextMessage(cid, 22, "You Assemble the Ancient Helmet")
        doPlayerAddItem(cid, 2342)
        doTeleportThing(cid, teleportTo)
    end
 
    return true
end


that work now! Thanks you very much!
 
Back
Top