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

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
help me with this error on my console please?

error:
Code:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/forgotten_knowledge/astral_source.lua:callback
...turescripts/quests/forgotten_knowledge/astral_source.lua:4: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        ...turescripts/quests/forgotten_knowledge/astral_source.lua:4: in function <...turescripts/quests/forgotten_knowledge/astral_source.lua:2>
> Broadcasted message: "Beware of Tyrn!".
[New Thread 0x7fffe7fff700 (LWP 16317)]
[Thread 0x7fffe7fff700 (LWP 16317) exited]
Reloaded: monster.

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>



scripts:
Lua:
local astralSource = CreatureEvent("AstralSource")
function astralSource.onThink(creature)
    local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
    local health, difference, glyph, pos, sourcePos = 0, 0, Tile(Position(863, 1346, 15)):getTopCreature(), creature:getPosition()
    if hp < 5.5 and Game.getStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph) >= 1 then
        sourcePos = creature:getPosition()
                local creatureHealth = creature:getHealth()
        creature:say('Your damage distorted the source and prevents the Glyph to draw on its power.', TALKTYPE_MONSTER_SAY)
        creature:remove()
        local source = Tile(Position(31986, 32823, 15)):getTopCreature()
        if source then
            source:teleportTo(sourcePos)
                        source:addHealth(-(source:getMaxHealth() - creatureHealth))
        end
        local spectators = Game.getSpectators(Position(31986, 32847, 14), false, false, 12, 12, 12, 12)
        for i = 1, #spectators do
            local spec = spectators[i]
            if spec:getName():lower() == 'a shielded astral glyph' then
                health = spec:getHealth()
                difference = glyph:getHealth() - health
                local pos = spec:getPosition()
                spec:teleportTo(Position(31989, 32823, 15))
                glyph:addHealth( - difference)
                glyph:teleportTo(pos)
                glyph:say('Without the power of the source the Glyph loses its protection!', TALKTYPE_MONSTER_SAY)
            end
        end
    elseif Game.getStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph) < 1 then
        creature:addHealth(10000, false)
    end
end
astralSource:register()
 
I've only glanced over the code on mobile and without testing.
I'd say tile doesn't exist and you are calling getTopCreature()

Tile(Position(863, 1346, 15)):getTopCreature()
 
Back
Top