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

Attempt to index a boolean value

Count Dracula

New Member
Joined
Jul 30, 2013
Messages
36
Solutions
1
Reaction score
1
Hello guys

I have no idea why i'm getting this error on my console, because the script is working perfectly.
I really can't see any errors...

Here is the error log:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/blood brothers quest/espelho.lua:onUse
.../actions/scripts/quests/blood brothers quest/espelho.lua:131: attempt to index a boolean value
stack traceback:
    [C]: in function '__index'
    .../actions/scripts/quests/blood brothers quest/espelho.lua:131: in function <.../actions/scripts/quests/blood brothers quest/espelho.lua:62>

And here is the full script:

Code:
local lordVampirePosition = Position(32967, 31457, 2)
local mirror1Position = Position(32965, 31457, 2)
local mirror2Position = Position(32966, 31456, 2)
local mirror3Position = Position(32968, 31456, 2)

local function transformVampire()
    local lordevampiro = Tile({ x=32967, y=31457, z=2}):getItemById(9242)
    if not lordevampiro then
        return true
        end
    
    lordevampiro:transform(9241)
end   

    local function clearArea(fromPosition, toPosition, exitPosition)
    for x = fromPosition.x, toPosition.x do
        for y = fromPosition.y, toPosition.y do
            for z = fromPosition.z, toPosition.z do
                local creature = Tile(Position(x, y, z)):getTopCreature()
                if creature then
                    if creature:isPlayer() then
                        creature:teleportTo(exitPosition)
                        exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
end

local function transformMirror1()
    local mirror1 = Tile(mirror1Position):getItemById(9637)
    if not mirror1 then
        return true
    end

    mirror1:transform(9583)
    mirror1:setActionId(12441)
end

local function transformMirror2()
    local mirror2 = Tile(mirror2Position):getItemById(9637)
    if not mirror2 then
        return true
    end

    mirror2:transform(9583)
    mirror2:setActionId(12442)
end

local function transformMirror3()
    local mirror3 = Tile(mirror3Position):getItemById(9637)
    if not mirror3 then
        return true
    end

    mirror3:transform(9583)
    mirror3:setActionId(12443)
end


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if item.actionid == 12441 and item.itemid == 9583 then
        if player:getStorageValue(Storage.BloodBrothersQuest.Mission08) == 1 and player:getStorageValue(Storage.BloodBrothersQuest.Espelho1) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho2) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho3) < os.time()  then
        player:setStorageValue(Storage.BloodBrothersQuest.Espelho1, os.time()+30)
        Tile({ x=32967, y=31457, z=2}):getItemById(9241):transform(9242)
        Tile({ x=32965, y=31457, z=2}):getItemById(9583):transform(9637)
        player:say("STOP THAT, YOU WORM, OR I'LL SHOW YOU THE BEAUTY OF DEATH.", TALKTYPE_MONSTER_SAY, false, nil, Position(32967, 31457, 2))
        event1 = addEvent(transformVampire, 1 * 30 * 1000, lordVampirePosition)   
        event2 = addEvent(transformMirror1, 1 * 30 * 1000)
            
        elseif player:getStorageValue(Storage.BloodBrothersQuest.Espelho2) > os.time() or player:getStorageValue(Storage.BloodBrothersQuest.Espelho3) > os.time()  then
            addEvent(clearArea, 1, Position(32964, 31456, 2), Position(32971, 31464, 2), Position(32966, 31462, 1))
            player:say("FINE! DIE PRETTY!", TALKTYPE_MONSTER_SAY, false, nil, Position(32966, 31462, 1))
            stopEvent(event1)
            stopEvent(event2)
            stopEvent(event3)
            stopEvent(event4)
            stopEvent(event5)
            stopEvent(event6)
            Tile({ x=32967, y=31457, z=2}):getItemById(9242):transform(9241)
            Tile({ x=32965, y=31457, z=2}):getItemById(9637):transform(9583):setActionId(12441)
            Tile({ x=32966, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12442)
            Tile({ x=32968, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12443)
        end
        end
        
        if item.actionid == 12442 and item.itemid == 9583 then
            if player:getStorageValue(Storage.BloodBrothersQuest.Mission08) == 1 and player:getStorageValue(Storage.BloodBrothersQuest.Espelho2) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho1) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho3) < os.time()  then
            player:setStorageValue(Storage.BloodBrothersQuest.Espelho2, os.time()+30)
                Tile({ x=32967, y=31457, z=2}):getItemById(9241):transform(9242)
                Tile({ x=32966, y=31456, z=2}):getItemById(9583):transform(9637)
                player:say("STOP THAT, YOU WORM, OR I'LL SHOW YOU THE BEAUTY OF DEATH.", TALKTYPE_MONSTER_SAY, false, nil, Position(32967, 31457, 2))
                event3 = addEvent(transformVampire, 1 * 30 * 1000, lordVampirePosition)
                event4 = addEvent(transformMirror2, 1 * 30 * 1000)
            elseif player:getStorageValue(Storage.BloodBrothersQuest.Espelho1) > os.time() or player:getStorageValue(Storage.BloodBrothersQuest.Espelho3) > os.time()  then
                addEvent(clearArea, 1, Position(32964, 31456, 2), Position(32971, 31464, 2), Position(32966, 31462, 1))
                player:say("FINE! DIE PRETTY!", TALKTYPE_MONSTER_SAY, false, nil, Position(32966, 31462, 1))
            stopEvent(event1)
            stopEvent(event2)
            stopEvent(event3)
            stopEvent(event4)
            stopEvent(event5)
            stopEvent(event6)
            Tile({ x=32967, y=31457, z=2}):getItemById(9242):transform(9241)
            Tile({ x=32965, y=31457, z=2}):getItemById(9637):transform(9583):setActionId(12441)
            Tile({ x=32966, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12442)
            Tile({ x=32968, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12443)
            end
        end
        
            if item.actionid == 12443 and item.itemid == 9583 then
                if player:getStorageValue(Storage.BloodBrothersQuest.Mission08) == 1 and player:getStorageValue(Storage.BloodBrothersQuest.Espelho3) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho1) < os.time() and player:getStorageValue(Storage.BloodBrothersQuest.Espelho2) < os.time()  then
                player:setStorageValue(Storage.BloodBrothersQuest.Espelho3, os.time()+30)
                Tile({ x=32967, y=31457, z=2}):getItemById(9241):transform(9242)
                Tile({ x=32968, y=31456, z=2}):getItemById(9583):transform(9637)
                player:say("STOP THAT, YOU WORM, OR I'LL SHOW YOU THE BEAUTY OF DEATH.", TALKTYPE_MONSTER_SAY, false, nil, Position(32967, 31457, 2))
                event5 = addEvent(transformVampire, 1 * 30 * 1000, lordVampirePosition)   
                event6 = addEvent(transformMirror3, 1 * 30 * 1000)
            elseif player:getStorageValue(Storage.BloodBrothersQuest.Espelho1) > os.time() or player:getStorageValue(Storage.BloodBrothersQuest.Espelho2) > os.time()  then
                addEvent(clearArea, 1, Position(32964, 31456, 2), Position(32971, 31464, 2), Position(32966, 31462, 1))
                player:say("FINE! DIE PRETTY!", TALKTYPE_MONSTER_SAY, false, nil, Position(32966, 31462, 1))
                    stopEvent(event1)
                    stopEvent(event2)
                    stopEvent(event3)
                    stopEvent(event4)
                    stopEvent(event5)
                    stopEvent(event6)
            Tile({ x=32967, y=31457, z=2}):getItemById(9242):transform(9241)
            Tile({ x=32965, y=31457, z=2}):getItemById(9637):transform(9583):setActionId(12441)
            Tile({ x=32966, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12442)
            Tile({ x=32968, y=31456, z=2}):getItemById(9637):transform(9583):setActionId(12443)
            end
        end
    return true
end

If anyone could help me I would be really glad.
 
Solution
Item:transform returns a boolean value, not an item / tile userdata value.
You can there for not use this:
Code:
Tile({ x=32965, y=31457, z=2}):getItemById(9637):transform(9583):setActionId(12441)

Code:
local tile = Tile(Position(32965, 31457, 2)):getItemById(9637)
tile:transform(9583)
tile:setActionId(12441)
Item:transform returns a boolean value, not an item / tile userdata value.
You can there for not use this:
Code:
Tile({ x=32965, y=31457, z=2}):getItemById(9637):transform(9583):setActionId(12441)

Code:
local tile = Tile(Position(32965, 31457, 2)):getItemById(9637)
tile:transform(9583)
tile:setActionId(12441)
 
Solution
Back
Top