• 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 Svargrond Arena TFS 1.2 error

Batalj

Member
Joined
May 26, 2017
Messages
51
Solutions
1
Reaction score
13
Hello there! I have been trying to solve this problem all night,

the error code in the console looks like this:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/arena.lua:onCreatureSay
data/npc/scripts/arena.lua:29: attempt to index global 'Storage' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/arena.lua:29: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:411: in function 'onCreatureSay'
        data/npc/scripts/arena.lua:7: in function <data/npc/scripts/arena.lua:7>
Lua Script Error: [Test Interface]
data/actions/scripts/quests/svargrond arena/arena_door.lua
data/actions/scripts/quests/svargrond arena/arena_door.lua:2: attempt to index global 'Storage' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/quests/svargrond arena/arena_door.lua:2: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/quests/svargrond arena/arena_door.lua

I have tried to look thru the Lib folder, the Npc folder and the arena script but havent got it to work right. Last thing I thought was that something should be added to the Lib folder but still doesnt work. Can someone try to help me get this to work?

Ill post the .lua here

First: data/npc/scripts/arena.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

keywordHandler:addKeyword({'rules'}, StdModule.say, {npcHandler = npcHandler, text = 'What do you want to know? Something about the three different {difficulties}, the {general} rules or the {prices}? Maybe you also want to know what happens when you {die}?'})
keywordHandler:addKeyword({'difficulties'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'levels'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'difficulty'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'greenhorn'}, StdModule.say, {npcHandler = npcHandler, text = 'That is the easiest way in our arena. The {fee} is 1000 gold. We were setting this up for of our children to challenge some easy monsters and train them for the future.'})
keywordHandler:addKeyword({'scrapper'}, StdModule.say, {npcHandler = npcHandler, text = 'The most common difficulty for us. The {fee} is 5000 gold. So if you are experienced in fighting middle class monsters this is your challenge!'})
keywordHandler:addKeyword({'warlord'}, StdModule.say, {npcHandler = npcHandler, text = 'Only the strongest among us will take this challenge. The {fee} is 10000 gold. If you pass that I promise you the respect of all citizens here. You will be a hero!'})
keywordHandler:addKeyword({'fee'}, StdModule.say, {npcHandler = npcHandler, text = 'The fee is either 1000, 5000 or 10000 gold for one try. Remember that if you {die}, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack.'})
keywordHandler:addKeyword({'die'}, StdModule.say, {npcHandler = npcHandler, text = 'It would be better not to die! In every pit there is an emergency exit, the portal to the south. If you die in a pit... well... your corpse and backpack are gone, so you enter the arena at your own risk.'})
keywordHandler:addKeyword({'general'}, StdModule.say, {npcHandler = npcHandler, text = 'Basically you pay me a {fee}, and you are sent into an arena with 10 different stages. If you succeed you will be rewarded accordingly.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'My job is to explain about the rules and to get the fee from the competitors.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'Well I would rather call it an {Ultimate Challenge} than a mission.'})

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if msgcontains(msg, 'fight') or msgcontains(msg, 'pit') or msgcontains(msg, 'challenge') or msgcontains(msg, 'arena') then
        if player:getStorageValue(Storage.SvargrondArena.Pit) == 1 then
            npcHandler:say('You already paid the fee, go and fight!', cid)
            return true
        end

        if arenaId < 1 then
            arenaId = 1
            player:setStorageValue(Storage.SvargrondArena.Arena, arenaId)
        end

        if ARENA[arenaId] then
            npcHandler:say('So you agree with the {rules} and want to participate in the {challenge}? The {fee} for one try in {' .. ARENA[arenaId].name .. '} is ' .. ARENA[arenaId].price .. ' gold pieces. Do you really want to participate and pay the {fee}?', cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You\'ve already completed the arena in all {difficulty levels}.', cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, 'yes') then
            if not ARENA[arenaId] then
                npcHandler.topic[cid] = 0
                return true
            end

            if player:removeMoney(ARENA[arenaId].price) then
                player:setStorageValue(Storage.SvargrondArena.Pit, 1)
                npcHandler:say('As you wish! You can pass the door now and enter the teleporter to the pits.', cid)

                local cStorage = ARENA[arenaId].questLog
                if player:getStorageValue(cStorage) ~= 1 then
                    player:setStorageValue(cStorage, 1)
                end
            else
                npcHandler:say('You do not have enough money.', cid)
            end
        else
            npcHandler:say('Come back when you are ready then.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello competitor! Do you want to {fight} in the arena or shall I explain the {rules} first?')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Second: data/actions/scripts/quests/svargrond arena/arena_door
Lua:
local storages = {
    [26100] = Storage.SvargrondArena.Greenhorn,
    [27100] = Storage.SvargrondArena.Scrapper,
    [28100] = Storage.SvargrondArena.Warlord
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Cannot use opened door
    if item.itemid == 5133 then
        return false
    end

    if player:getStorageValue(Storage.SvargrondArena.Arena) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This door seems to be sealed against unwanted intruders.')
        return true
    end

    -- Doors to rewards
    local cStorage = storages[item.actionid]
    if cStorage then
        if player:getStorageValue(cStorage) ~= 1 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'It\'s locked.')
            return true
        end

        item:transform(item.itemid + 1)
        player:teleportTo(toPosition, true)

    -- Arena entrance doors
    else
        if player:getStorageValue(Storage.SvargrondArena.Pit) ~= 1 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This door seems to be sealed against unwanted intruders.')
            return true
        end

        item:transform(item.itemid + 1)
        player:teleportTo(toPosition, true)
    end

    return true
end
Thanks for some kind of tips how to make this work properly.

Regards Batalj

Seems that all thats needed is a place to get the 'Storage', just my thoughts...
 
Last edited by a moderator:
Solution
Now when I try to open up it all gets buggy, it seems that the svargrondArenaQuest is just messing everything up basically. Its when I do this in core.lua

Code:
dofile('data/lib/core/svargrondArenaQuest.lua')

Then it gets all messy, should I place it in another folder?

Where did you get the datapack if the ORTS code isn't in it?
You should try to place them in the same place - to make them easier to find; server/data/lib/miscellaneous/svargrondArenaQuest.lua

But if you arn't using ORTS you probbly can't use the ORTS code, since they use a lib file for storage values, they might have diffrent function names etc
So check what datpack you got before you replace just 1 file, in that case replace everything that has to do with the...
assuming you are using ORTS?

server/051-storages.lua at master · orts/server · GitHub

Code:
Storage = {
    SvargrondArena = {
        Arena = 1100,
        Pit = 1101,

        QuestLogGreenhorn = 50140,
        QuestLogScrapper = 50141,
        QuestLogWarlord = 50142,

        RewardGreenhorn = 26300,
        RewardScrapper = 27300,
        RewardWarlord = 28300,

        TrophyGreenhorn = 1103,
        TrophyScrapper = 1105,
        TrophyWarlord = 1107,

        -- Reward Doors
        Greenhorn = 26100,
        Scrapper = 27100,
        Warlord = 28100
    }
}
 
Got a new error now, thanks emil

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/arena.lua:onCreatureSay
data/npc/scripts/arena.lua:41: attempt to index global 'ARENA' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/arena.lua:41: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:411: in function 'onCreatureSay'
        data/npc/scripts/arena.lua:7: in function <data/npc/scripts/arena.lua:7>

arena.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

keywordHandler:addKeyword({'rules'}, StdModule.say, {npcHandler = npcHandler, text = 'What do you want to know? Something about the three different {difficulties}, the {general} rules or the {prices}? Maybe you also want to know what happens when you {die}?'})
keywordHandler:addKeyword({'difficulties'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'levels'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'difficulty'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'greenhorn'}, StdModule.say, {npcHandler = npcHandler, text = 'That is the easiest way in our arena. The {fee} is 1000 gold. We were setting this up for of our children to challenge some easy monsters and train them for the future.'})
keywordHandler:addKeyword({'scrapper'}, StdModule.say, {npcHandler = npcHandler, text = 'The most common difficulty for us. The {fee} is 5000 gold. So if you are experienced in fighting middle class monsters this is your challenge!'})
keywordHandler:addKeyword({'warlord'}, StdModule.say, {npcHandler = npcHandler, text = 'Only the strongest among us will take this challenge. The {fee} is 10000 gold. If you pass that I promise you the respect of all citizens here. You will be a hero!'})
keywordHandler:addKeyword({'fee'}, StdModule.say, {npcHandler = npcHandler, text = 'The fee is either 1000, 5000 or 10000 gold for one try. Remember that if you {die}, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack.'})
keywordHandler:addKeyword({'die'}, StdModule.say, {npcHandler = npcHandler, text = 'It would be better not to die! In every pit there is an emergency exit, the portal to the south. If you die in a pit... well... your corpse and backpack are gone, so you enter the arena at your own risk.'})
keywordHandler:addKeyword({'general'}, StdModule.say, {npcHandler = npcHandler, text = 'Basically you pay me a {fee}, and you are sent into an arena with 10 different stages. If you succeed you will be rewarded accordingly.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'My job is to explain about the rules and to get the fee from the competitors.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'Well I would rather call it an {Ultimate Challenge} than a mission.'})

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if msgcontains(msg, 'fight') or msgcontains(msg, 'pit') or msgcontains(msg, 'challenge') or msgcontains(msg, 'arena') then
        if player:getStorageValue(Storage.SvargrondArena.Pit) == 1 then
            npcHandler:say('You already paid the fee, go and fight!', cid)
            return true
        end

        if arenaId < 1 then
            arenaId = 1
            player:setStorageValue(Storage.SvargrondArena.Arena, arenaId)
        end

        if ARENA[arenaId] then
            npcHandler:say('So you agree with the {rules} and want to participate in the {challenge}? The {fee} for one try in {' .. ARENA[arenaId].name .. '} is ' .. ARENA[arenaId].price .. ' gold pieces. Do you really want to participate and pay the {fee}?', cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You\'ve already completed the arena in all {difficulty levels}.', cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, 'yes') then
            if not ARENA[arenaId] then
                npcHandler.topic[cid] = 0
                return true
            end

            if player:removeMoney(ARENA[arenaId].price) then
                player:setStorageValue(Storage.SvargrondArena.Pit, 1)
                npcHandler:say('As you wish! You can pass the door now and enter the teleporter to the pits.', cid)

                local cStorage = ARENA[arenaId].questLog
                if player:getStorageValue(cStorage) ~= 1 then
                    player:setStorageValue(cStorage, 1)
                end
            else
                npcHandler:say('You do not have enough money.', cid)
            end
        else
            npcHandler:say('Come back when you are ready then.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello competitor! Do you want to {fight} in the arena or shall I explain the {rules} first?')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Now when I try to open up it all gets buggy, it seems that the svargrondArenaQuest is just messing everything up basically. Its when I do this in core.lua

Code:
dofile('data/lib/core/svargrondArenaQuest.lua')

Then it gets all messy, should I place it in another folder?
 
Now when I try to open up it all gets buggy, it seems that the svargrondArenaQuest is just messing everything up basically. Its when I do this in core.lua

Code:
dofile('data/lib/core/svargrondArenaQuest.lua')

Then it gets all messy, should I place it in another folder?

Where did you get the datapack if the ORTS code isn't in it?
You should try to place them in the same place - to make them easier to find; server/data/lib/miscellaneous/svargrondArenaQuest.lua

But if you arn't using ORTS you probbly can't use the ORTS code, since they use a lib file for storage values, they might have diffrent function names etc
So check what datpack you got before you replace just 1 file, in that case replace everything that has to do with the arena.
 
Solution
Thanks WibbenZ, I manage to change movements and lib folders, so now its all good. Still got some small errors ingame, but that isnt giving any console errors and are probebly just the management of the files.
 
Back
Top