• 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 spell console

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
Does anyone know why I get this error with this spell on my console?

My storages are fine

i used otbr tfs 1.3

Code:
GlobalStorage = {
    DangerousDepths = {
        -- Reserved storage from 60001 - 60009
        Geodes = {
            WarzoneVI = 60001,
            WarzoneV = 60002,
            WarzoneIV = 60003
        }
    },
    DreamScar = {
            maxxeniusTimer = 531902,
            alptramunTimer = 531903,
            plaguerootTimer = 531904,
            izcandarTimer = 531905,
            malofurTimer = 531906,

            alptramunSummonsKilled = 531907,
            izcandarOutfit = 531908,
            nightmareTimer = 531909,
            lastBossCurse = 531910,
    },

ERROR
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/monster/alptramun_summon.lua:onCastSpell
data/spells/scripts/monster/alptramun_summon.lua:22: attempt to index field 'DreamCourts' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/spells/scripts/monster/alptramun_summon.lua:22: in function <data/spells/scripts/monster/alptramun_summon.lua:17>
spell.lua


Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SOUND_PURPLE)

local area = createCombatArea(AREA_CIRCLE2X2)
combat:setArea(area)

local config = {
    [1] = {name = "unpleasant dream"},
    [2] = {name = "horrible dream"},
    [3] = {name = "nightmarish dream"},
    [4] = {name = "mind-wrecking dream"}
}

local maxsummons = 5

function onCastSpell(creature, var)

    local monsterName = ""
    local randomName = math.random(1, #config)
    local randomSummon = math.random(1, 4)
    local summonsKilled = Game.getStorageValue(GlobalStorage.DreamScar.alptramunSummonsKilled) or -1
    if summonsKilled >= 0 and summonsKilled <= 9 then
        monsterName = config[1].name
    elseif summonsKilled > 9 and summonsKilled <= 18 then
        monsterName = config[2].name
    elseif summonsKilled > 18 and summonsKilled <= 27 then
        monsterName = config[3].name
    elseif summonsKilled > 27 and summonsKilled <= 36 then
        monsterName = config[4].name
    else
        monsterName = config[randomName].name
    end

    local summoncount = creature:getSummons()
    if #summoncount < maxsummons then
        for i = 1, randomSummon do
            local mid = Game.createMonster(monsterName, creature:getPosition())
                if not mid then
                    return
                end
            mid:setMaster(creature)
            mid:registerEvent("dreamCourtsDeath")
        end
    end
    return combat:execute(creature, var)
end
 
Last edited:
Are you sure this is the correct script that is erroring?

I don't see anything related to the error here.
 
It had run a few lines down, go again, it was a bad copy

note: that's why I put the storage
Alright, well if you're sure it's this code that's erroring, here's a bunch of prints.

Tell me what shows up in console.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SOUND_PURPLE)

local area = createCombatArea(AREA_CIRCLE2X2)
combat:setArea(area)

local config = {
    [1] = {name = "unpleasant dream"},
    [2] = {name = "horrible dream"},
    [3] = {name = "nightmarish dream"},
    [4] = {name = "mind-wrecking dream"}
}

local maxsummons = 5

function onCastSpell(creature, var)
    print(1)
    local monsterName = ""
    print(2)
    local randomName = math.random(1, #config)
    print(3)
    local randomSummon = math.random(1, 4)
    print(4)
    local summonsKilled = Game.getStorageValue(GlobalStorage.DreamScar.alptramunSummonsKilled) or -1
    print(5)
    if summonsKilled >= 0 and summonsKilled <= 9 then
        print(6)
        monsterName = config[1].name
    elseif summonsKilled > 9 and summonsKilled <= 18 then
        print(7)
        monsterName = config[2].name
    elseif summonsKilled > 18 and summonsKilled <= 27 then
        print(8)
        monsterName = config[3].name
    elseif summonsKilled > 27 and summonsKilled <= 36 then
        print(9)
        monsterName = config[4].name
    else
        print(10)
        monsterName = config[randomName].name
    end
    print(11)
    local summoncount = creature:getSummons()
    if #summoncount < maxsummons then
        print(12)
        for i = 1, randomSummon do
            print(13)
            local mid = Game.createMonster(monsterName, creature:getPosition())
            if not mid then
                print(14)
                return
            end
            mid:setMaster(creature)
            mid:registerEvent("dreamCourtsDeath")
            print(15)
        end
    end
    print(16)
    return combat:execute(creature, var)
end
 
Alright, well if you're sure it's this code that's erroring, here's a bunch of prints.

Tell me what shows up in console.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SOUND_PURPLE)

local area = createCombatArea(AREA_CIRCLE2X2)
combat:setArea(area)

local config = {
    [1] = {name = "unpleasant dream"},
    [2] = {name = "horrible dream"},
    [3] = {name = "nightmarish dream"},
    [4] = {name = "mind-wrecking dream"}
}

local maxsummons = 5

function onCastSpell(creature, var)
    print(1)
    local monsterName = ""
    print(2)
    local randomName = math.random(1, #config)
    print(3)
    local randomSummon = math.random(1, 4)
    print(4)
    local summonsKilled = Game.getStorageValue(GlobalStorage.DreamScar.alptramunSummonsKilled) or -1
    print(5)
    if summonsKilled >= 0 and summonsKilled <= 9 then
        print(6)
        monsterName = config[1].name
    elseif summonsKilled > 9 and summonsKilled <= 18 then
        print(7)
        monsterName = config[2].name
    elseif summonsKilled > 18 and summonsKilled <= 27 then
        print(8)
        monsterName = config[3].name
    elseif summonsKilled > 27 and summonsKilled <= 36 then
        print(9)
        monsterName = config[4].name
    else
        print(10)
        monsterName = config[randomName].name
    end
    print(11)
    local summoncount = creature:getSummons()
    if #summoncount < maxsummons then
        print(12)
        for i = 1, randomSummon do
            print(13)
            local mid = Game.createMonster(monsterName, creature:getPosition())
            if not mid then
                print(14)
                return
            end
            mid:setMaster(creature)
            mid:registerEvent("dreamCourtsDeath")
            print(15)
        end
    end
    print(16)
    return combat:execute(creature, var)
end
Lua:
1
2
3
4
5
10
11
12
13
15
13
15
16
1
2
3
4
5
10
11
12
13
15
13
15
16
1
2
3
4
5
10
11
12
13
15
13
15
16
1
2
3
4
5
10
11
16
Captura.PNG
 
So.. no error?

Appears to be fully functioning?
now there is no mistake, if you create the summons


Do you know anything about this error?
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/startup/others/functions.lua:192: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/startup/others/functions.lua:192: in function 'preyTimeLeft'
        data/events/scripts/player.lua:712: in function <data/events/scripts/player.lua:676>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/startup/others/functions.lua:192: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/startup/others/functions.lua:192: in function 'preyTimeLeft'
        data/events/scripts/player.lua:712: in function <data/events/scripts/player.lua:676>
 
now there is no mistake, if you create the summons
More then likely you changed something and forgot to save or forgot to /reload

Since nothing in the script has changed, that's the only logical conclusion, based on the error and feedback.
Do you know anything about this error?
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/startup/others/functions.lua:192: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/startup/others/functions.lua:192: in function 'preyTimeLeft'
        data/events/scripts/player.lua:712: in function <data/events/scripts/player.lua:676>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/startup/others/functions.lua:192: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/startup/others/functions.lua:192: in function 'preyTimeLeft'
        data/events/scripts/player.lua:712: in function <data/events/scripts/player.lua:676>
Only what you've shown here.

It's attempting to index a nil value in the function preyTimeLeft
 
Back
Top