I would like to make a cooking system where when you are within a certain radius, a menu opens with the certain food you can currently take.
The following modules are in play:
GameDataManager
CookingManager
The annoying part is, it doesn’t seem to work.
When I want to execute the module to see which specific foods is available, I want it to send back the string of the available foods.
The recipes are found in the gamedata so they are easily changeable and the checker is inside of cooking manager.
When attempting, it returns “Currently available: Tomato” even though that is not a food and isn’t the full list of ingredients there are.
The following image is me with a TOMATO and a LAVENDER in my backpack activating the checker using THIS script below (check below image)
local GameDataManager = require(game.ReplicatedStorage:WaitForChild("Modules").GameData)
local CookingManager = require(game.ReplicatedStorage:WaitForChild("Modules").CookingManager)
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
for i, v in pairs(CookingManager:CheckMaterials(plr)) do
print("Can Cook:" .. v[i])
end
end)
This is the recipes:
GameData.Recipes = {
["Baked Potato"] = {
"Lavender"
},
["Fancy Dinner"] = {
"Tomato","Lavender"
}
}
This is the checker to see if the user has the specific items and SHOULD return a table with strings of currently available meals like “Fancy Dinner” but doesn’t.
local Stations = workspace.Interactables.Stations:GetChildren()
local Recipes = GameDataManager.Recipes
function module:CheckMaterials(plr)
for _, foodName in pairs(Recipes) do
for i, foodIngredience in pairs(foodName) do
local canCook = {}
if plr.Backpack:FindFirstChild(foodIngredience) or plr.Character:FindFirstChild(foodIngredience) then
table.insert(canCook,1,foodName)
end
return canCook
end
end
end