Hi,
How would i achieve the making of a crafting system?, What would i check for, what do i put in a table ect, (no dragging of items ui)
Thank you
Hi,
How would i achieve the making of a crafting system?, What would i check for, what do i put in a table ect, (no dragging of items ui)
Thank you
So if you really simplify the problem all you would be doing is comparing tables together. You’d have a list of recipes and just compare the contents of the two tables.
local Recipes = {
RandomItem = {
"Steel";
"Wood";
"Stone";
};
};
--Sorting to enforce order
for k,v in pairs(Recipes) do
Recipes[k] = table.sort(v);
end
local function GetCraftingItemFromUI()
--return table.sort(table of items from the ui);
end;
local function FindItemGivenRecipe()
local CraftingItems = GetCraftingItemFromUI();
for k,v in pairs(Recipes) do
local Compare = true;
for i = 1,#v do
if v[i] ~= CraftingItems[i] then
Compare = false;
break;
end
if Compare then
return k;
end
end
end
end;
Once you start getting a lot more items in your recipe book, it won’t be very efficient to check every single recipe so you’d want to look into a more efficient data structure.