• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Server coming up with a issue

Zombiegod

Active Member
Joined
Oct 22, 2009
Messages
198
Solutions
1
Reaction score
25
okay so im trying to convert a 8.4 mystic spirit data to 8.6 crying damson data

at the moment im having a error come up its

[24/03/2014 07:52:40] [Error - Npc interface]
[24/03/2014 07:52:40] data/npc/scripts/loot.lua
[24/03/2014 07:52:40] Description:
[24/03/2014 07:52:40] data/npc/lib/npcsystem/modules.lua:1093: attempt to index local 'v' (a boolean value)
[24/03/2014 07:52:40] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/loot.lua

Ive checked all the scripting, and compared it to a working one (aka the original data), and they are identical, even the npc is identical

ima keep this open and update when i come up with more problems, thanks any help will be appreciated

P.S. no im not gonna use any other server, and yes i am doing this as i really like this server, but want it more updated
 
first one is loot, and the second is vip loot, they both come up with the same error

Code:
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

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'clubs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy dragon hammers(2k), skull staffs(6k), war hammers(1.2k), dragonbone staffs(3k) and daramanian maces(110gp). I also buy amber staffs(8k), sapphire hammers(2k), brutetamer\s staff(1.5k), furry clubs(1k), taurus maces(500gp), lunar staffs(5k), mammoth whoppers(300gp) and diamond sceptres(3k).'})
keywordHandler:addKeyword({'axes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy knight axes(2k), dragon lances(9k), fira axes (8k), obsidian lances(500gp), war axes(9k) and daramanian waraxes (1k). I also buy beastslayer axe(1.5k).'})
keywordHandler:addKeyword({'swords'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy giant swords (17k), poison daggers (50gp), scimiteras (150gp), serpent sword (900gp), fire sword (4k), spike swords(1k), ice rapiers(1k), broad swords(500gp), dragon slayers(15k), wyvern fang(1.5k), silver dagger(500gp) and heavy machetes(90gp).'})
keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy magic lightwands(30gp), wand of vortexes(100gp), wand of dragonbreaths(200gp), wand of plagues(1k), wand of cosmic energys(2k) and wand if infernoes(3k).'})
keywordHandler:addKeyword({'rods'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy snakebite rods(100gp), moonlight rods(200gp), volcanic rods(1k), quarmire rods(2k) and tempest rods(3k).'})
keywordHandler:addKeyword({'boots'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy boots of hastes(30k), steel boots(30k), pirate boots(2k) and crocodile boots(1k). I also buy fur boots(2k).'})
keywordHandler:addKeyword({'armors'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy crown armors(12k), blue robes(10k), noble armors(900gp), dark armors(400gp), knight armors(5k), dragon scale mails(40k), golden armors(20k) and pirate scirts(500gp). I also buy mammoth fur capes(6k), leopard armors(1k).'})
keywordHandler:addKeyword({'legs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy crown legs(12k), knight legs(5k) and pirate knee breeches(200gp).'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy phoenix shields(16k), crown shields(8k), dragon shields(4k), guardian shields(2k), beholder shields(1.2k), ancient shields(900gp), black shields, tower shields(8k), vampire shields(15k), demon shields(30k), medusa shields(9k), castle shields(5k), scarab shields(2k), dark shields(400gp), tortoise shields(150gp) and bone shields(80gp).'})
keywordHandler:addKeyword({'helmets'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy royal(30k), crusader(6k), crown(2.5k), dark(250gp), strange(500gp), warrior(5k), skull(40k), beholder(7.5k), devil(1k), ragnir(400gp) and krimhorn(200gp). I also buy mystic turbans(150gp) and pirate hats(1k).'})

npcHandler:addModule(FocusModule:new())

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'clubs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy dragon hammers(2k), skull staffs(6k), war hammers(1.2k), dragonbone staffs(3k) and daramanian maces(110gp). I also buy amber staffs(8k), sapphire hammers(2k), brutetamer\s staff(1.5k), furry clubs(1k), taurus maces(500gp), lunar staffs(5k), mammoth whoppers(300gp) and diamond sceptres(3k).'})
keywordHandler:addKeyword({'axes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy knight axes(2k), dragon lances(9k), fira axes (8k), obsidian lances(500gp), war axes(9k) and daramanian waraxes (1k). I also buy beastslayer axe(1.5k).'})
keywordHandler:addKeyword({'swords'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy giant swords (17k), poison daggers (50gp), scimiteras (150gp), serpent sword (900gp), fire sword (4k), spike swords(1k), ice rapiers(1k), broad swords(500gp), dragon slayers(15k), wyvern fang(1.5k), silver dagger(500gp) and heavy machetes(90gp).'})
keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy magic lightwands(30gp), wand of vortexes(100gp), wand of dragonbreaths(200gp), wand of plagues(1k), wand of cosmic energys(2k) and wand if infernoes(3k).'})
keywordHandler:addKeyword({'rods'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy snakebite rods(100gp), moonlight rods(200gp), volcanic rods(1k), quarmire rods(2k) and tempest rods(3k).'})
keywordHandler:addKeyword({'boots'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy boots of hastes(30k), steel boots(30k), pirate boots(2k) and crocodile boots(1k). I also buy fur boots(2k).'})
keywordHandler:addKeyword({'armors'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy crown armors(12k), blue robes(10k), noble armors(900gp), dark armors(400gp), knight armors(5k), dragon scale mails(40k), golden armors(20k) and pirate scirts(500gp). I also buy mammoth fur capes(6k), leopard armors(1k).'})
keywordHandler:addKeyword({'legs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy crown legs(12k), knight legs(5k) and pirate knee breeches(200gp).'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy phoenix shields(16k), crown shields(8k), dragon shields(4k), guardian shields(2k), beholder shields(1.2k), ancient shields(900gp), black shields, tower shields(8k), vampire shields(15k), demon shields(30k), medusa shields(9k), castle shields(5k), scarab shields(2k), dark shields(400gp), tortoise shields(150gp) and bone shields(80gp).'})
keywordHandler:addKeyword({'helmets'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy royal(30k), crusader(6k), crown(2.5k), dark(250gp), strange(500gp), warrior(5k), skull(40k), beholder(7.5k), devil(1k), ragnir(400gp) and krimhorn(200gp). I also buy mystic turbans(150gp) and pirate hats(1k).'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
 
The indexing problem is not in the scripts you posted - it's in modules.lua.

You should post that (or look at the function that includes line 1093).
 
this is the line thats bad, the exact parts are underlined, also the reason its coming up with arrows makes no sense as this is the default lib file that came with the crying damson server

function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = getItemInfo(itemid)
if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
local item = {
id = itemid,
buy = -1,
sell = cost,
subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
name = realName or v.name
}

for i, shopItem in ipairs(self.npcHandler.shopItems) do
if(shopItem.id == item.id and shopItem.subType == item.subType) then
if(item.buy ~= shopItem.buy) then
item.buy = shopItem.buy
end

self.npcHandler.shopItems = item
item = nil
break
end
end

if(item ~= nil) then
table.insert(self.npcHandler.shopItems, item)
end
end
 
try replacing it with this:
PHP:
function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = getItemInfo(itemid)
    if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
    local item = {
    id = itemid,
    buy = -1,
    sell = cost,
    subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
    name = realName or v.name
    }

    for i, shopItem in ipairs(self.npcHandler.shopItems) do
        if(shopItem.id == item.id and shopItem.subType == item.subType) then
            if(item.buy ~= shopItem.buy) then
            item.buy = shopItem.buy
            end

        self.npcHandler.shopItems = item
        item = nil
        break
        end
    end

        if(item ~= nil) then
        table.insert(self.npcHandler.shopItems, item)
        end
    end
end
 
now i get


[25/03/2014 00:28:11] [Error - Npc interface]
[25/03/2014 00:28:11] data/npc/scripts/food.lua
[25/03/2014 00:28:11] Description:
[25/03/2014 00:28:11] data/npc/scripts/food.lua:3: attempt to index global 'NpcSystem' (a nil value)
[25/03/2014 00:28:12] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/food.lua

with every npc i have
 
The extra "end" was to close the function :)

just for testing.. try this:
PHP:
function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = {}
local v = getItemInfo(itemid)
    if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
    local item = {
    id = itemid,
    buy = -1,
    sell = cost,
    subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
    name = realName or v.name
    }

    for i, shopItem in ipairs(self.npcHandler.shopItems) do
        if(shopItem.id == item.id and shopItem.subType == item.subType) then
            if(item.buy ~= shopItem.buy) then
            item.buy = shopItem.buy
            end

        self.npcHandler.shopItems = item
        item = nil
        break
        end
    end

        if(item ~= nil) then
        table.insert(self.npcHandler.shopItems, item)
        end
    end
end
 
let me correct your script right now
Code:
function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = {}
local v = getItemInfo(itemid)
    if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
    local item = {
    id = itemid,
    buy = -1,
    sell = cost,
    subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
    name = realName or v.name
    }

    for i, shopItem in ipairs(self.npcHandler.shopItems) do
        if(shopItem.id == item.id and shopItem.subType == item.subType) then
            if(item.buy ~= shopItem.buy) then
            item.buy = shopItem.buy
            end

        self.npcHandler.shopItems = item
        item = nil
        break
        end
    end

        if(item ~= nil) then
        table.insert(self.npcHandler.shopItems, item)
        end
    end

you have one to many ends, as par to the rule of scripting, for every function and if, have a end, this script has 1 function 4 if, and 5 end, you are adding a extra unneeded end thats cause it to close the entire script, i could highlight all the end if you like

also that came up with the same error, v a boolean value
 
let me correct your script right now
Code:
function ShopModule:addSellableItem(names, itemid, cost, realName)
local v = {}
local v = getItemInfo(itemid)
    if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
    local item = {
    id = itemid,
    buy = -1,
    sell = cost,
    subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
    name = realName or v.name
    }

    for i, shopItem in ipairs(self.npcHandler.shopItems) do
        if(shopItem.id == item.id and shopItem.subType == item.subType) then
            if(item.buy ~= shopItem.buy) then
            item.buy = shopItem.buy
            end

        self.npcHandler.shopItems = item
        item = nil
        break
        end
    end

        if(item ~= nil) then
        table.insert(self.npcHandler.shopItems, item)
        end
    end

you have one to many ends, as par to the rule of scripting, for every function and if, have a end, this script has 1 function 4 if, and 5 end, you are adding a extra unneeded end thats cause it to close the entire script, i could highlight all the end if you like

also that came up with the same error, v a boolean value



yeah, you do have 4 if.. and 1 function... but you forgot 1 thing..

PHP:
for i, shopItem in ipairs(self.npcHandler.shopItems) do

This is also something that need an end..
in source/php it wouldn't need it because { } but in lua it does need them =)

So yes, you are in need of an extra end :)
 
"attempt to index local 'v' (a boolean value)"
tells us that you're not getting the return you expect from "getItemInfo(itemid)".
The script expects a table, and you're getting either "true" or "false"

I don't have access to your server code, but FWIW in TFS 1.0 that function is gone.
 
Last edited:
"attempt to index local 'v' (a boolean value)"
tells us that you're not getting the return you expect from "getItemInfo(itemid)".
The script expects a table, and you're getting either "true" or "false"

I don't have access to your server code, but FWIW in TFS 1.0 that function is gone.

I'll list the possible replacements in my next post
im not using version 10.31, 8.6 or aka tfs 0.3.6, so yes its still there


yeah, you do have 4 if.. and 1 function... but you forgot 1 thing..

PHP:
for i, shopItem in ipairs(self.npcHandler.shopItems) do

This is also something that need an end..
in source/php it wouldn't need it because { } but in lua it does need them =)

So yes, you are in need of an extra end :)

lol theres a part i did not post as its not part of the problem, at least i dont think so

Code:
    function ShopModule:addSellableItem(names, itemid, cost, realName)
        local v = getItemInfo(itemid)
        if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
            local item = {
                id = itemid,
                buy = -1,
                sell = cost,
                subType = ((v.charges > 0 and v.stackable) and v.charges or 0),
                name = realName or v.name
            }

            for i, shopItem in ipairs(self.npcHandler.shopItems) do
                if(shopItem.id == item.id and shopItem.subType == item.subType) then
                    if(item.buy ~= shopItem.buy) then
                        item.buy = shopItem.buy
                    end

                    self.npcHandler.shopItems[i] = item
                    item = nil
                    break
                end
            end

            if(item ~= nil) then
                table.insert(self.npcHandler.shopItems, item)
            end
        end

        if(names ~= nil and SHOPMODULE_MODE ~= SHOPMODULE_MODE_TRADE) then
            local parameters = {
                itemid = itemid,
                cost = cost,
                eventType = SHOPMODULE_SELL_ITEM,
                module = self,
                realName = realName or v.name
            }

            for i, name in pairs(names) do
                local keywords = {}
                table.insert(keywords, 'sell')
                table.insert(keywords, name)

                local node = self.npcHandler.keywordHandler:addKeyword(keywords, ShopModule.tradeItem, parameters)
                node:addChildKeywordNode(self.yesNode)
                node:addChildKeywordNode(self.noNode)
            end
        end
    end
 
You definitely nailed the code that generated the message first time:

"local v = getItemInfo(itemid)" is setting "v" to true or false, but the script expects a table, and
"subType = ((v.charges > 0 and v.stackable) and v.charges or 0)" fails because "v.charges" requires a table with a "charges=xxx" entry.

Without your server code I can't test further, but if you have an easy way to capture output, check the datatype of "itemid" just before running "local v = getItemInfo(itemid)".
"type(itemid)" returns the datatype as a string.

If it's nil the cause of the problem is somewhere up the chain.

Also check to see if the script has a function called getItemInfo() in it, and maybe check compat.lua (if you have one) too.
 
You definitely nailed the code that generated the message first time:

"local v = getItemInfo(itemid)" is setting "v" to true or false, but the script expects a table, and
"subType = ((v.charges > 0 and v.stackable) and v.charges or 0)" fails because "v.charges" requires a table with a "charges=xxx" entry.

Without your server code I can't test further, but if you have an easy way to capture output, check the datatype of "itemid" just before running "local v = getItemInfo(itemid)".
"type(itemid)" returns the datatype as a string.

If it's nil the cause of the problem is somewhere up the chain.

Also check to see if the script has a function called getItemInfo() in it, and maybe check compat.lua (if you have one) too.

well im useing roxor 8.4, to find the exact version im using, search "roxor tibia" and goto my father's site should be the first link, im trying to convert that to a blank crying damson 8.6 or tfs 0.3.6
 
Back
Top