obsidian/MyObsidianVault/Godot/2D/Tutorial M7 - Telling a story/M7.L10 - Talking wiith emotion/Arrays of dictionaries.md
2024-12-22 12:24:50 +01:00

1.1 KiB

var inventory: Array[Dictionary] = [
	{
		"name": "sword",
		"amount": 1,
	},
	{
		"name": "potion",
		"amount": 5,
	},
	{
		"name": "potion",
		"amount": 3,
	},
	{
		"name": "coins",
		"amount": 65,
	},
]

[]

var expressions := {
	"happy" : preload("res://assets/emotion_happy.png"),
	"regular" : preload("res://assets/emotion_regular.png"),
	"sad" : preload("res://assets/emotion_sad.png"),
}

var dialogue_items: Array[Dictionary]= [
{
	"expression": expressions["regular"],
	"text": "I'm learning about Arrays..."
},
{
	"expression": expressions["sad"],
	"text": "... and it is a little bit complicated."
},
{
	"expression": expressions["happy"],
	"text": "Let's see if I got it right: an array is a list of values!",
},
{
	"expression": expressions["regular"],
	"text": "Did I get it right? Did I?",
},
{
	"expression": expressions["happy"],
	"text": "Hehe! Bye bye~!",
	},
]

func show_text() -> void:
	var current_item := dialogue_items[current_item_index]
	rich_text_label.text = current_item["text"]
	expression.texture = current_item["expression"]