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

Add ability to pass dialogic variables as args to dialogic event signals #2404

Open
Anomalous-Sentiment opened this issue Sep 17, 2024 · 1 comment
Labels
Enhance ⚡ Improve a feature's workflow. Events Feature✨

Comments

@Anomalous-Sentiment
Copy link

Anomalous-Sentiment commented Sep 17, 2024

Is your feature request related to a problem? Please describe.
The idea is to add the ability to use Dialogic variables as args for event signals instead of directly using values or "magic numbers" for better readability & maintenance.

Describe the solution you'd like
The ability to pass Dialogic variables as args to event signals, for example in the text editor:

[signal arg=foo.bar.id]

or for dictionaries, something like:

[signal arg_type="dict" arg="{"id":foo.bar.id}"]

where foo.bar.id is an int variable to be passed as an arg to the signal..

Describe alternatives you've considered
A working alternative solution that was suggested was to use:
[signal arg_type="dict" arg="{"id":"foo.bar.id"}"]

and receive the signal using:

func _on_dialogic_signal(arg:Variant) -> void:
     print(Dialogic.VAR.get_variable(arg.id))

which is one method to avoid using "magic numbers", although there is some overhead.

Additional context
In my use case, I was trying to create an RPG with a system where player can obtain items through dialogue and at certain points, I wanted signals to be emitted when an item is obtained, and to identify what item was obtained.

The idea was to pass an item ID to the signal, and let the receiver handle the rest, but that would require manually typing in the item ID into the Dialogic text editor, effectively making it a magic number.

Another issue was that in the scenario that the item ID(s) changed, then that could potentially cause issues with all the places where that ID was used. Using a variable would solve this as we could simply reference the variable, and if that value needs to be changed in the future, only the value of the single variable would need to be changed, making readability & maintenance significantly easier.

@Jowan-Spooner Jowan-Spooner added Feature✨ Events Enhance ⚡ Improve a feature's workflow. labels Sep 17, 2024
@Jowan-Spooner
Copy link
Collaborator

This sounds like a good addition, however most likely what it will mean is the syntax will be:
[signal arg_type="dict" arg="{"id":{foo.bar.id}}"]

In a very similar direction it would probably be really useful to allow variables/expressions as any paramter value in shortcode events, e.g.:

[wait time={SomeVariable}]
[text_input text={"Change your name (Current name is "+{Player.Name}+")"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhance ⚡ Improve a feature's workflow. Events Feature✨
Projects
None yet
Development

No branches or pull requests

2 participants