Struggeling with an actual gameplay loop

godot 4.3

extends Control

@onready var tea_image = $Tea_Done  # Replace with your actual image node
@onready var coffee_image = $Coffee_Done  # Replace with your actual image node
@onready var boiling_sound = %Boiling
@onready var water_sound = %Water

var ingredients: Dictionary = {
	"coffee": 0,
	"tea": 0,
	"milk": 0,
	"sugar": 0,
}

var drinks = {
	"Coffee": ["Coffee", "Sugar", "Milk"],
	"Tea": ["Tea", "Sugar", "Milk"]
	}

func _on_tea_pressed() -> void:
	pass # Replace with function body.

I’m just not sure how to code this, I want ingredients to be able to be selected and once the right combination of ingredients is selected you can brew them at the coffee machine to get a drink. Then the customer gives money & satisfaction points and then the next customer comes repeat.

I cannot find any tutorials on this and this is how far im able to get on my own.
Does anyone know how i can manage this?

It’s too easy, just do like this:

var ingredients_selected = false

func _on_tea_pressed() -> void:
	update_ingredients("tea")

func update_ingredients(type):
    ingredients[type] += 1
    
    var is_everything_selected = true
    for i in ingredients:
        var value = ingredients[i]
        if value == 0: is_everything_selected = false
    
    ingredients_selected = is_everything_selected

func check_recipe():
    if ingredients["tea"] > 0: print("It's tea")
    elif ingredients["coffee"] > 0: print("It's coffee")
   # var current_ingredients = []
   # for i in ingredients:
   # if ingredients[i] > 0: current_ingredients.append(i)

func _physics_process():
    if ingredients_selected: check_recipe()

It’s just the basic concept, so adjust it as you want.

2 Likes