paulloz/godot-ink

System.NullReferenceException: Object reference not set to an instance of an object. when calling TagsForContentAtPath

Closed this issue · 2 comments

Describe the bug
I'm trying to use the TagsForContentAtPath function to get the tags at a knot called "answer". But I'm getting an error which I can't make sense of.

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
  at InkStory.TagsForContentAtPath (System.String pathString) [0x00001] in C:\Users\Joel\Documents\Godot\cyoa-prototype-v2\addons\paulloz.ink\InkStory.cs:422

This is how my knot looks.

=== answer ===
  Man am I glad someone answered! # Man am I glad someone answered!
  I'm in real danger here. # I'm in real danger here.
  The whole city has been overrun with clam zombies. # The whole city has been overrun with clam zombies.
  Luckily, I managed to find an intact submarine where the coms still functioned. # Luckily, I managed to find an intact submarine where the coms still functioned.

To Reproduce
I have this code where I'm calling the function. I'm not doing anything special other than call the function.

func handle_current_game_state():
	var test = ink_story.TagsForContentAtPath("answer")
	print(test)
	var is_waiting = ink_story.GetVariable("is_waiting")
	if is_waiting and !is_waiting_active:
		show_is_waiting_text()
	elif !is_waiting and !is_waiting_active:
		progress_story()

Environment

  • OS: Windows 10
  • Godot version: 3.3 mono
  • godot-ink version: 0.8
  • ink version: 1.0

So I realised by scouring the ink documentation that knot tags should be at the beginning of a knot for the TagsForContentAtPath function to work. After I changed from this

=== answer ===
  Man am I glad someone answered! # Man am I glad someone answered!
  I'm in real danger here. # I'm in real danger here.
  The whole city has been overrun with clam zombies. # The whole city has been overrun with clam zombies.
  Luckily, I managed to find an intact submarine where the coms still functioned. # Luckily, I managed to find an intact submarine where the coms still functioned.

to this

=== answer ===
# Man am I glad someone answered!
# I'm in real danger here.
# The whole city has been overrun with clam zombies.
# Luckily, I managed to find an intact submarine where the coms still functioned.
Man am I glad someone answered! 
I'm in real danger here. 
The whole city has been overrun with clam zombies. 
Luckily, I managed to find an intact submarine where the coms still functioned.

it worked.

I'll still investigate whether the exception occurs in godot-ink code or further up.