Heya, I’ve been working on a cooking system where you put 3 ingredients into a table and if the ingredients align with a dish, it’ll output the dish. (Ex: You put one burger one patty and one cheese and it outputs a burger) I’ve been trying to wrap my head around how I should handle this and I’ve been stumped. My main idea is to compare two tables, one with the current ingredients, and one with all the recipes. How should I go about this?
local Recipes = {
["Burger"] = {"Bread", "CookedPatty", "Cheese"},
["Soda"] = {"SodaCup, SodaLid"}
}
return Recipes
-- Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local CookingRecipes = require(ServerScriptService.Modules.CookingRecipes)
local Ingredients = script.Parent:WaitForChild("Ingredients")
local PrxoimityPrompt = script.Parent:WaitForChild("ProximityPrompt")
local MaxIngredients = 3
local CurrentIngredients = {}
-- Cook Ingredients
PrxoimityPrompt.Triggered:Connect(function(player)
-- Put Ingredients
if player.PlayerStats.HoldingObject.Value ~= nil then
if #Ingredients:GetChildren() < MaxIngredients then
local Ingredient = Instance.new("StringValue")
Ingredient.Parent = Ingredients
Ingredient.Name = "Ingredient"
Ingredient.Value = player.PlayerStats.HoldingObject.Value.Name
player.PlayerStats.HoldingObject.Value:Destroy()
player.PlayerStats.HoldingObject.Value = nil
table.insert(CurrentIngredients, Ingredient.Value)
print(CurrentIngredients)
end
end
local TotalIngredients = Ingredients:GetChildren()
if #Ingredients:GetChildren() == MaxIngredients then
-- Output Ingredients
end
end)