Godot 3.1.1 - [Fixed] Invalid set index on base Nil with value of type

Hi guys, I am going through the tutorial and working on lesson 19. StoryBook Option 1: Story Objects

After implementing the changes for the Export Var : PoolStringArray etc. I get the following error message

Invalid set index 'prompts' (on base: 'Nil') with value of type 'PoolStringArray'

Trying to debug this error it shows current_story as [null] so I think something could be wrong with this code but I can’t see why it doesn’t assign the correct child as the current_story

current_story.prompts = $StoryBook.get_child(selected_story).prompts
current_story.story = $StoryBook.get_child(selected_story).story


extends Control

var headline = "Looney Lips ALPHA - 0.2"
var welcome_message = "Welcome to Looney Lips. Follow the instructions. "

var player_words = []

#var story_template = [
#		{
#		"prompts" : ["One", "Two", "Three", "Four", "Five"],
#		"story" : "%s thinks that %s is %s then %s so far. Looking promising %s."
#		},
#		{
#		"prompts" : ["Who benefits from this?", "Who is this harmful to", "Who makes decisions about this", "Who is most directly affected", "Who have you also heard discussing this?"],
#		"story" : "%s are the beneficiaries of this. It could be harmful to %s. The decision makers are %s. Those directly affected are %s. Additional people discussing this %s."
#		}
#		]

var current_story

onready var HeadlineText = $VBoxContainer/HeadlineText
onready var PlayerText = $VBoxContainer/HBoxContainer/PlayerText
onready var DisplayText = $VBoxContainer/DisplayText
onready var SubmitButtonText = $VBoxContainer/HBoxContainer/TextureButton/SubmitButtonText

func _ready():
	DisplayText.text = welcome_message
	HeadlineText.text = headline

func set_current_story():
	var stories = $StoryBook.get_child_count()
	var selected_story = randi() % stories
	current_story.prompts = $StoryBook.get_child(selected_story).prompts
	current_story.story = $StoryBook.get_child(selected_story).story
#	current_story = story_template[randi() % story_template.size()]

func _on_PlayerText_text_entered(new_text):

func _on_TextureButton_pressed():
	if is_story_done():

func add_to_player_words():
	DisplayText.text = ""

func is_story_done():
	return player_words.size() == current_story.prompts.size()

func check_player_words_length():
	if is_story_done():

func tell_story():
	DisplayText.text = current_story.story % player_words

func prompt_player():
	PlayerText.grab_focus() # grab_focus focuses the keyboard on the inputfield PlayerText
	DisplayText.text += "May I have " + current_story.prompts[player_words.size()] + " please?"

func end_game():
	PlayerText.queue_free() # Free the things that we are not using in the program any longer.
	SubmitButtonText.text = "Again?"


extends Node

export var prompts : PoolStringArray
export var story : String

I really appreciate the help as I am trying to figure our and understand this error.

// Pheonix Lucror

I found the problem.

When var current_story is declared I had missed initializing it with the correct type. adding = {} to it worked.

problem was: var current_story

should be: var current_story = {}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.