godot 4.3
first time using gdscript and godot, gamejam ends this friday, im lost
extends Control
@onready var colleague = %Colleague
@onready var astral = %Astral
@onready var astro = %Astro
@onready var mimi = %Mimi
@onready var rin = %Rin
@onready var woolie = %Woolie
@onready var heart = $Heart
@onready var dialogue = %Dialogue
var dialogue_start: bool = false
var clicked: bool = false
var colleague_dialogue_lines = [
"Hey, you must be the new hire!",
"I can already tell we are going to be besties, or cesties? Like colleagues and besties!",
".....",
"no?",
"Ok let's get you started",
"We have four drink recipes, make sure to remember them",
"To make a coffee you need coffeebeans, Milk and sugar",
"To make a tea you need matcha and sugar",
"To make a matcha latte you need matcha and milk",
"and finally for a hot chocolate you need chocolate, milk and sugar",
"When you have selected the correct ingredients you press on the drink machine to brew the drink",
"Now with that being said",
] # Colleague's unique dialogue lines
func _ready() -> void:
button_blink()
dialogue.connect("gui_input", Callable(self, "_on_dialogue_clicked"))
func _process(_float) -> void:
if colleague.visible:
colleague_dialogue()
func colleague_dialogue():
if colleague.visible == true:
# Start the dialogue when the colleague is visible
await get_tree().create_timer(1.0).timeout
self.visible = true
show_dialogue(colleague_dialogue_lines) # Call function to show dialogue lines
# Function to display dialogue line by line
func show_dialogue(lines: Array) -> void:
if dialogue_start:
return
dialogue_start = true
var typing_speed = 0.05 # Speed of typing
dialogue.text = "" # Clear previous text
for line: String in lines:
dialogue.text = ""
var chars = line.split("", true) # Split the line into individual characters for typing effect
for c in chars:
dialogue.text += c # Add one character at a time
await get_tree().create_timer(typing_speed).timeout
await wait_for_input()
dialogue_start = false
func wait_for_input() -> void:
clicked = false # Reset flag
while not clicked:
await get_tree().process_frame # Wait for dialogue click
func _on_dialogue_clicked(event):
if event is InputEventMouseButton and event.pressed:
clicked = true
# Function to make the button blink
func button_blink():
var tween = create_tween().set_loops()
tween.tween_property(heart, "visible", false, 0.8)
tween.tween_property(heart, "visible", true, 0.8)