Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait()
- local queue = script.Parent.Queues
- function addToQueue(plr, food)
- local tycoon = game.Workspace:FindFirstChild(plr.Values.Tycoon.Value)
- local foodData = game.ReplicatedStorage.FoodData:FindFirstChild(food)
- -- Get empty slot
- local slot = getEmptySlot()
- if slot == nil then return "No Available Slots" end
- -- If ingredients then look for them
- if foodData.Ingredients.Value == true then
- for _, i in ipairs(foodData.Ingredients:GetChildren()) do
- if not gotIngredients(i.Name, i.Value, tycoon) then
- return "Missing Ingredients"
- end
- end
- takeInredients(food, tycoon)
- end
- slot.Value = food
- cook()
- return "Succes"
- end
- script.RemoteCook.OnServerInvoke = addToQueue
- function gotIngredients(food, amount, tycoon)
- for _, i in ipairs(tycoon.Values.Food:GetChildren()) do
- if i.Name == food then
- if i.Value >= amount then
- return true
- end
- end
- end
- return false
- end
- function takeInredients(food, tycoon)
- for _, i in ipairs(game.ReplicatedStorage.FoodData:FindFirstChild(food).Ingredients:GetChildren()) do
- tycoon.Values.Food:FindFirstChild(i.Name).Value = tycoon.Values.Food:FindFirstChild(i.Name).Value - i.Value
- end
- end
- function getEmptySlot()
- if queue.Cooking.Value == "" then return queue.Cooking end
- for _, i in ipairs(queue:GetChildren()) do
- if i.Value == "" then
- return i
- end
- end
- return nil
- end
- local db = false
- function cook()
- local cooking = queue.Cooking
- if cooking.Value == "" then return end -- If the value is nothing, then return
- if db == true then return end
- db = true
- while cooking.Progress.Value < game.ReplicatedStorage.FoodData:FindFirstChild(cooking.Value).Time.Value do
- wait(0.05)
- cooking.Progress.Value = cooking.Progress.Value + 0.05
- end
- script.Parent.Parent.Parent.Parent.Values.Food:FindFirstChild(cooking.Value).Value = script.Parent.Parent.Parent.Parent.Values.Food:FindFirstChild(cooking.Value).Value + 1
- cooking.Progress.Value = 0
- db = false
- moveQueue()
- end
- queue.Cooking.Changed:Connect(function() cook() end)
- function moveQueue()
- queue.Cooking.Value = ""
- wait()
- queue.Cooking.Value = queue:FindFirstChild("1").Value
- for v, i in ipairs(queue:GetChildren()) do
- if i.Name ~= "1" and i.Name ~= "Cooking" then
- queue:FindFirstChild(tonumber(i.Name) - 1).Value = i.Value
- end
- end
- queue:FindFirstChild(queue.Value).Value = ""
- cook()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement