Closed Hot-Cuddleccino closed 2 years ago
You're right. I can replicate this and now I know why that happens.
The node is being added in the same frame that all options are being removed. Thank you for pointing this out.
Instead of avoiding removing options, we can deffer the signal call to make sure that every option node was removed before adding new ones.
So this
Will be this
option_button.connect("pressed", self, "emit_signal", ["option_selected", option], CONNECT_DEFERRED|CONNECT_ONESHOT)
I am glad I could help!
Instead of avoiding removing options, we can deffer the signal call to make sure that every option node was removed before adding new ones.
I wasn't trying to avoid removing, I moved it in the _on_OptionButton_pressed
function. I should have made that more clear.
In my humble opinion, if you don't mind, I would try to not use one signal connected to two functions in the same node and also the name remove_options
doesn't follow expected naming for signal-handling function.
Thank you for making this addon.
OS
Kde Neon 5.23. (Ubuntu)
Godot Version
3.4. stable
Plugin Version
1.0 (lastest)
Issue description
File: options_node.gd.
Signals were "sometimes" executed in bad order. (around 10% chance for the game run)
If one uses the
on_option_selected
signal to change dialog text and add new options:It is weird that it either works this way or is ok depending on the game start (maybe when signals are connected, I have no inside knowledge on this).
Steps to reproduce
var dialog = null
func _ready() -> void: dialog = DialogNode.instance() add_child(dialog) dialog.options_manager.connect("option_selected", self, "_on_option_selected") dialog.show() dialog.show_text("Hello world!") dialog.add_option("Hello program!")
func _on_option_selected(option: String) -> void: match option: "Hello program!": dialog.show_text("Hello again!") dialog.add_option("Hello!") "Hello!": dialog.show_text("Hi human") dialog.add_option("Hello program!")
into this:
The problem is no longer there (but I cannot promise it won't break anything else)