Challenge

It took me longer than I’d like to admit to figure out how to display the opening text and wait for the player to click ok to continue. This is a very silly story and I admittedly didn’t put much thought into it.


extends Node2D

var player_words = [] # the words the player chooses.
var introduction = "Welcome to Loony Lips!  We're going to have so many laughs together.  If you will give me just a few different types of words, I'll tell you a very funny story."
var prompt = ["a noun", "a verb", "a color", "an animal", "a body part", "an adjective"]
var story = "Once upon a time, there was a %s who loved to %s.  She loved it so much that she did it every day.  One day she came across a %s %s who chased her.  While running, she hurt her %s and magically it became very %s."
var intro_shown = false

func _ready():
	$Blackboard/StoryText.text = introduction
	$Blackboard/TextBox.text = "Press the OK button to continue."
#	prompt_player()

func _on_TextureButton_pressed():
	if intro_shown == true:
		var new_text = $Blackboard/TextBox.get_text()
		_on_TextBox_text_entered(new_text)
	else:
		intro_shown == true
		$Blackboard/TextBox.text = ""
		prompt_player()

func _on_TextBox_text_entered(new_text):
	player_words.append(new_text)
	$Blackboard/TextBox.text = ""
	check_player_word_length()
	

func prompt_player():
	$Blackboard/StoryText.text = ("Can I have " + prompt[player_words.size()] + ", please?")
	

func check_player_word_length():
	if player_words.size() == prompt.size():
		tell_story()
	else:
		prompt_player()

func tell_story():
	$Blackboard/StoryText.text = story % player_words

Update: I edited my script to more closely match Yann’s and changed the intro text slightly.

Second Attempt:

func _ready():
	$Blackboard/StoryText.text = "Welcome to Loony Lips!  We are going to have an amazing time together.  If you'll just give me a few words, I'll give you funny stories.  \n\n\nCan I have " + prompt[player_words.size()] + " please?"
	$Blackboard/TextBox.text = ""

Privacy & Terms