Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jump not working on timeline created by code #2492

Open
SymbiontZ opened this issue Dec 3, 2024 · 2 comments
Open

jump not working on timeline created by code #2492

SymbiontZ opened this issue Dec 3, 2024 · 2 comments
Labels
Bug 🐞 Something isn't working Needs testing More feedback/testing would be good

Comments

@SymbiontZ
Copy link

The problem

Using jump node in a timeline created by code results on error that says:
Trying to assign value of type 'Nil' to a variable of type 'String'.

Stacked Fotograms:
0 - res://addons/dialogic/Core/DialogicResourceUtil.gd:65 - at function: get_unique_identifier
1 - res://addons/dialogic/Modules/jump/event_label.gd:22 - at function: _execute

To Reproduce

  1. Create a scene with a Node2D.
  2. Create a script with:
func _ready():
	var timeline: DialogicTimeline = DialogicTimeline.new()
	var evento = get_event(preguntas)
	timeline.events = evento
	timeline.events_processed = true
	Dialogic.start(timeline)
	Dialogic.timeline_ended.connect(_on_dialog_ended)
	
func _on_dialog_ended() -> void:
	Dialogic.timeline_ended.disconnect(_on_dialog_ended)
        print("dialogue completed correctly")
        
func get_event() -> Array:
	var event: Array = """
	hellooo
	jump test
	good bye!
	
	label test
	test text
	""".split("\n")
	return event
  1. Assign the script to the scene node created before.
  2. Press Execute current escene button (F6)

Expected behavior
I expected to get the correct sequence of dialogue:

  • hellooo
  • test text
  • good bye!

Screenshots
imagen_2024-12-03_121627174

System (please complete the following information):

  • OS: Windows 11
  • Godot Version: 4.3.estable
  • Dialogic Version: 2.0. Alpha 16

Solutions

I didn't reach any solution

I tried write jump/label "test", jump/label TEST, jump/label Test

Possible fixes

I have no idea sorry.

@Jowan-Spooner Jowan-Spooner added Bug 🐞 Something isn't working Needs testing More feedback/testing would be good labels Dec 3, 2024
@samuel-walker
Copy link
Contributor

samuel-walker commented Dec 4, 2024

Hey @SymbiontZ, I just ran into this exact issue last week. @Jowan-Spooner suggested they might be able to remove the requirement that timelines have a valid path for resource_path and that they appear in the project settings dtl directory list. That is the ultimate source of this issue. In the meantime, I've developed a rather clunky workaround if you want to use it. You have to save your code-created timeline as a resource. I am using a temporary folder and clearing it regularly since my timelines are one-time-use only.

Here's what my version looks like:

# Save resource path for use (needed by Jump events)
var res_path: String = dialogic.current_timeline.resource_path

# Build custom events
var events: Array = get_events()

# Create timeline from events
var embedded_timeline: DialogicTimeline = DialogicTimeline.new()
embedded_timeline.events = events
embedded_timeline.events_processed = true

# Append custom events to current timeline
var current_events: Array = dialogic.current_timeline_events
var copy: Array = current_events.duplicate()
dialogic.current_timeline_events = Utilities.insert_array_at_index(copy, events, dialogic.current_event_idx + 1)

# Create and save brand new timeline to fix current_timeline issue
var full_timeline: DialogicTimeline = DialogicTimeline.new()
full_timeline.events = dialogic.current_timeline_events
full_timeline.events_processed = true
dialogic.current_timeline = full_timeline
dialogic.current_timeline_events = full_timeline.events
var temp_name: String = "timeline_{0}.dtl".format([Time.get_ticks_usec()])
var temp_path: String = "res://dialogic/timelines/temp/" + temp_name
dialogic.current_timeline.resource_path = temp_path
ResourceSaver.save(dialogic.current_timeline, temp_path)
# Setting meta here because Dialogic expects it
if Engine.has_meta("dtl_directory"):
var new_dict: Dictionary = Engine.get_meta("dtl_directory")
new_dict[temp_name] = temp_path

There may be a better way to do this, but it seems to work for me now.

@Jowan-Spooner
Copy link
Member

This exact crash might be fixed by #2480, though I'm not sure if that fixes timelines created in code entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Something isn't working Needs testing More feedback/testing would be good
Development

No branches or pull requests

3 participants