Item list (2 categories, imagine numerous items within each category).
local biglist = {
["Items"] = {
{
Name = "Test Item";
Type = "Sword";
UUID = nil;
};
},
["Consumables"] = {
{
Name = "Vigilant Ash";
Type = "Consumable";
UUID = nil;
};
}
}
The actual script (one gives outs a warning even though it succeeds):
local item = invmod:retrieveItemFromData("Test Item")
local item2 = invmod:retrieveItemFromData("Vigilant Ash")
The module script that is called, I may be doing something wrong here, that’s why I need help.
local function checkItemExistence(itemData)
for _,v in pairs(itemsData) do
for i,x in pairs(v) do
if x.Name == itemData.Name then
return true
else
return false
end
end
end
end
function inventoryHandler:retrieveItemFromData(item)
for _,v in pairs(itemsData) do
for i,x in pairs(v) do
if x.Name == item then
return x
elseif checkItemExistence(itemsData) == false then
warn(x.Name .." does not exist in the game data, please check for typos.")
end
end
end
end
This is the output:
23:28:20.582 - Test Item does not exist in the game data, please check for typos.
Test Item 43FF5060-C92C-4AAE-B4C8-0E9073E13F38
As you can see the table contradicts itself since it does receive Test Item but it still says it does not exist, and also its not taking the “Vigilant Ash” which it’s supposed to print out as well.