viniciusgerevini / godot-clyde-dialogue

Clyde Dialogue Language Importer and interpreter for Godot.
MIT License
89 stars 11 forks source link

ability to set variables on parse/start #7

Closed verillious closed 2 years ago

verillious commented 2 years ago

it would be cool to be able to store certain variables when the .clyde file is parsed, or when ClydeDialogue.start() is ran maybe something like

{ global name = "npc_name", color = "red" } etc.

I'm currently trying to store a dictionary of character info in my .clyde files and this would reduce a lot of code workarounds!

viniciusgerevini commented 2 years ago

Hello @verillious. If I understood it correctly, you would like to have some variables that would always be set, regardless of block executed. Is that right?

I mean, currently if you do something like

{ set name = "npc_name", color = "red" }

== this_is_a_block
npc: %name% ....

The variables in the first line will only be available if the default block was executed. The idea is to have some kind of initial setup that is always ran. Did I get it right? What kind of workarounds are you doing?

verillious commented 2 years ago

You know what - I don't think this is really necessary! I just looked over my code and it's actually really simple to do what I want with the built-in stuff from the plugin!

  1. define everything you want at the top of the file
  2. grab the content
  3. check for the variables you're interested in and do stuff with them
  4. parse the content

I'd written a next_line() function that did steps 2 and 4 "in one" so was forgetting I could do it this way.

So the workarounds I'd written were weirdly enough working around my own code 🤦‍♂️

I've just written a start() function that goes through 2 3 and 4 and it's working perfectly. Tbh it makes me love Clyde even more (I already loved it a lot ;) ) I could maybe think of a reason to have some sort of "always - available" variable if pushed but it might just be adding unnecessary complexity.

Sorry for wasting time!

viniciusgerevini commented 2 years ago

It's really nice of you to say that. Thanks. I'm glad you were able to find a solution.

It's not a waste of time at all, suggestions are always welcome, keep them coming :)

Good luck with your project.