function localGroup:addItem(item)
local i
for i = 1, maxItems do
print(i) -- prints 1 through 6 (maxItems = 6)
if items[i] == nil then
items[i] = item
db:exec([[REPLACE INTO inventory (slot, itemId, description, quantity, inuse, icon, width, height, location) VALUES (]] .. i .. [[,"]] .. items[i].id .. [[","]] .. items[i].name .. [[","]] .. "1" .. [[","]] .. "1" .. [[","]] .. items[i].availableIcon .. [[","]] .. items[i].width .. [[","]] .. items[i].height .. [[","]] .. "pack" ..[[");]])
break;
end
end
print(i) -- prints "nil"
print(maxItems)
if i \> maxItems then return false end -- errors here because its nil
return true
end
i should be “6” or less when it his that print statement.
Any ideas?
[import]uid: 19626 topic_id: 16706 reply_id: 316706[/import]