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

Lua Error console

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
I have this error in the console, can someone help me?

apparently that's when they kick me out of this room

ERRORs.png

CONSOLE.png

Lua:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/lib/core/game.lua:118: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/lib/core/game.lua:118: in function 'setStorageValue'
        data/lib/core/functions.lua:239: in function <data/lib/core/functions.lua:220>


Code:
local config = {
    centerPos = {Position({x = 31986, y = 32846, z = 14}), Position({x = 31985, y = 32847, z = 15})},
    rangeX = 20,
    rangeY = 27,
    {newPosition = Position(31985, 32851, 14)},
    {pos = Position(31986, 32840, 14), monster = 'a shielded astral glyph'},
    {pos = Position(31975, 32856, 15), monster = 'bound astral power'},
    {pos = Position(31987, 32839, 14), monster = 'the astral source'},
    {pos = Position(31986, 32823, 15), monster = 'the distorted astral source'},
    {pos = Position(31989, 32823, 15), monster = 'an astral glyph'}
}

local forgottenKnowledgeLastLore = Action()
function forgottenKnowledgeLastLore.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        if player:getPosition() ~= Position(32019, 32844, 14) then
            item:transform(9826)
            return true
        end
    end
    local spectators = Game.getSpectators(config.centerPos[1], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(spectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    local secondFloorSpectators = Game.getSpectators(config.centerPos[2], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(secondFloorSpectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    if item.itemid == 9825 then
        for xx = 14, 15 do
        local spectators = Game.getSpectators(Position(31986, 32846, 14), false, false, 21, 21, 21, 21)
            for i = 1, #spectators do
                spec = spectators[i]
                if spec:isPlayer() then
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with The Last Lore Keeper.")
                    return true
                end
            end
        end
        for x = 32018, 32020 do
            for y = 32844, 32848 do
                local playerTile = Tile(Position(x, y, 14)):getTopCreature()
                if playerTile and playerTile:isPlayer() then
                    if playerTile:getStorageValue(Storage.ForgottenKnowledge.LastLoreTimer) < os.time() then
                        playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
                        playerTile:teleportTo(config[1].newPosition)
                        playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                        playerTile:setStorageValue(Storage.ForgottenKnowledge.LastLoreTimer, os.time() + 60 * 60 * 14 * 24)
                    else
                        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait a while, recently someone challenge The Last Lore Keeper.")
                        return true
                    end
                end
            end
        end
            for _, creature in pairs(spectators) do
        creature:remove()
        end
        for _, creature in pairs(secondFloorSpectators) do
        creature:remove()
        end
        for b = 2, #config do
            Game.createMonster(config[b].monster, config[b].pos, true, true)
        end
        Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralPowerCounter, 1)
        Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph, 0)
        player:say('The Astral Glyph begins to draw upon bound astral power to expel you from the room!', TALKTYPE_MONSTER_SAY)
        addEvent(clearForgotten, 30 * 60 * 1000, Position(31968, 32821, 14), Position(32004, 32865, 15), Position(32035, 32859, 14))
        item:transform(9826)
        elseif item.itemid == 9826 then
        item:transform(9825)
    end
    return true
end

forgottenKnowledgeLastLore:aid(24884)
forgottenKnowledgeLastLore:register()
 
Solution

Some calls don't seem to be providing storage.
Add this before Game.setStorageValue(storage, 0)
Lua:
if not storage then
    return
end
game.lua:118: table index is nil
one of these keys is nil
Lua:
Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralPowerCounter, 1)
Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph, 0)

Make sure that both GlobalStorage.ForgottenKnowledge.AstralPowerCounter and GlobalStorage.ForgottenKnowledge.AstralGlyph exist.

 
one of these keys is nil
Lua:
Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralPowerCounter, 1)
Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph, 0)

Make sure that both GlobalStorage.ForgottenKnowledge.AstralPowerCounter and GlobalStorage.ForgottenKnowledge.AstralGlyph exist.

Apparently if they exist in storage

Code:
    ForgottenKnowledge = {
        -- Reserved storage from 60090 - 60099
        ActiveTree = 60090,
        MechanismGolden = 60091,
        MechanismDiamond = 60092,
        GoldenServant = 60093,
        DiamondServant = 60094,
        AstralPowerCounter = 60095,
        AstralGlyph = 60096
    },
 
they exist in storage
in that case confirm that the script can access those keys.

add these lines before calling Game.setStorageValue ( Line 73 )
Lua:
print('GS: ' .. tostring(GlobalStorage))
print('FK: ' .. tostring(GlobalStorage.ForgottenKnowledge))
print('AstralPowerCounter: ' .. tostring(GlobalStorage.ForgottenKnowledge.AstralPowerCounter))
print('AstralGlyph: ' .. tostring(GlobalStorage.ForgottenKnowledge.AstralGlyph))
 
in that case confirm that the script can access those keys.

add these lines before calling Game.setStorageValue ( Line 73 )
Lua:
print('GS: ' .. tostring(GlobalStorage))
print('FK: ' .. tostring(GlobalStorage.ForgottenKnowledge))
print('AstralPowerCounter: ' .. tostring(GlobalStorage.ForgottenKnowledge.AstralPowerCounter))
print('AstralGlyph: ' .. tostring(GlobalStorage.ForgottenKnowledge.AstralGlyph))

when I use the lever it throws this at the console

Lua:
GS: table: 0x400c8688
FK: table: 0x400c9588
AstralPowerCounter: 60095
AstralGlyph: 60096

when kicking me out of the room it throws me this error on the console

Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/lib/core/game.lua:118: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/lib/core/game.lua:118: in function 'setStorageValue'
        data/lib/core/functions.lua:239: in function <data/lib/core/functions.lua:220>
 
what have you got in functions.lua line 220?
Lua:
function clearForgotten(fromPosition, toPosition, exitPosition, storage)
    for x = fromPosition.x, toPosition.x do
        for y = fromPosition.y, toPosition.y do
            for z = fromPosition.z, toPosition.z do
                if Tile(Position(x, y, z)) then
                    local creature = Tile(Position(x, y, z)):getTopCreature()
                    if creature then
                        if creature:isPlayer() then
                            creature:teleportTo(exitPosition)
                            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                            creature:say("Time out! You were teleported out by strange forces.", TALKTYPE_MONSTER_SAY)
                        elseif creature:isMonster() then
                            creature:remove()
                        end
                    end
                end
            end
        end
    end
    Game.setStorageValue(storage, 0)
end
ERROR22.png
 

Some calls don't seem to be providing storage.
Add this before Game.setStorageValue(storage, 0)
Lua:
if not storage then
    return
end
 
Solution

Some calls don't seem to be providing storage.
Add this before Game.setStorageValue(storage, 0)
Lua:
if not storage then
    return
end
Now it only tells me this when I enter, it no longer gives me an error in the console when it kicks me

Lua:
GS: table: 0x4456d340
FK: table: 0x41e36c30
AstralPowerCounter: 60095
AstralGlyph: 60096




put in functions.lua like this:

Code:
function clearForgotten(fromPosition, toPosition, exitPosition, storage)
    for x = fromPosition.x, toPosition.x do
        for y = fromPosition.y, toPosition.y do
            for z = fromPosition.z, toPosition.z do
                if Tile(Position(x, y, z)) then
                    local creature = Tile(Position(x, y, z)):getTopCreature()
                    if creature then
                        if creature:isPlayer() then
                            creature:teleportTo(exitPosition)
                            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
                            creature:say("Time out! You were teleported out by strange forces.", TALKTYPE_MONSTER_SAY)
                        elseif creature:isMonster() then
                            creature:remove()
                        end
                    end
                end
            end
        end
    end
    if not storage then
    return
end
    Game.setStorageValue(storage, 0)
end
....png
 

Some calls don't seem to be providing storage.
Add this before Game.setStorageValue(storage, 0)
Lua:
if not storage then
    return
end
Look at the script calling this function.
It never supplies the storage in the addEvent.

Stopping the error this way doesn't solve the issue correctly.
 
Stopping the error this way doesn't solve the issue correctly.
True.

It is best to figure out from which script clearForgotten was called and figure out which storage should be set to 0. But since I dont know more than what has been provided here OP will have to figure that out sooner or later. 🤷‍♂️
 
True.

It is best to figure out from which script clearForgotten was called and figure out which storage should be set to 0. But since I dont know more than what has been provided here OP will have to figure that out sooner or later. 🤷‍♂️
line 76 in his main post. xD
 
Back
Top