
Greetings. How would I be able to check if a recipe is matching?
Put all the current ingredients in a table and send it via BindableEvent yes, but how do I compare it with the recipe?
Not only that but how do I count how many of each ingredient I have when sending it?
Cheers
To compare two tables (in your case, the tables representing recipes), you can use this simple function:
local function check_table_equality(t1, t2)
for k, v in pairs(t1) do if v ~= t2[k] then return false end end
for k, v in pairs(t2) do if v ~= t1[k] then return false end end
return true
end
The way it works should be pretty clear.
1 Like