• 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 table problem

andu

Sold 649 scripts, 25 maps and 9 events!
Joined
Aug 7, 2009
Messages
978
Solutions
17
Reaction score
373
GitHub
olrios
Twitch
jamagowy
error:
Code:
[17/05/2012 16:14:03] data/npc/scripts/t/t_1.lua:224: attempt to get length of field '?' (a nil value)
[17/05/2012 16:14:03] stack traceback:
[17/05/2012 16:14:03] 	data/npc/scripts/t/t_1.lua:224: in function 'getRequiredThings'
[17/05/2012 16:14:03] 	data/npc/scripts/t/t_1.lua:289: in function 'callback'
[17/05/2012 16:14:03] 	data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[17/05/2012 16:14:03] 	data/npc/scripts/t/t_1.lua:207: in function <data/npc/scripts/t/t_1.lua:207>

here is bugged function:
LUA:
local function getRequiredThings(cid)
local itemsleft = {}
local check = {}

for t = 1, 6 do
	check[t] = ""
	for i,x in pairs(cfg.quests[t].itemsReq) do
		local item = getPlayerItemCount(cid, i)
		if (item < x.amount) then
			table.insert(itemsleft[t], x.amount - item.. "x "..getItemNameById(i))
		end
	end
	check[t] = #itemsleft[t] > 0 and "Items: "..table.concat(itemsleft[t], ", ") or "" -- bugged (line 224)
end
return check[1], check[2], check[3], check[4], check[5], check[6]
end

bugged line:
LUA:
		check[t] = #itemsleft[t] > 0 and "Items: "..table.concat(itemsleft[t], ", ") or ""
 
Back
Top