-
-
Notifications
You must be signed in to change notification settings - Fork 195
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 the ability to expand variables inside of dialog #25
Comments
This is something I'd like to add. It needs two things to happen first: variables need to be able to store values other than numbers, and we need to figure out how localisation works, since this proposed feature would be affected by it.
|
I know I'm coming in doe-eyed and fresh faced, but I've been reviewing the code and I think there's a lot of potential here if the I'm noodling around with a concept like this in a branch. Didn't know if there were serious potholes ahead if I continued with this approach. Thanks again! |
Right. If variables are going to store any additional types besides floats, There's really only one specific thing to keep in mind: existing games will need to not be broken by changes. So you'll need to do it in a backwards-compatible way. |
Any work on this will likely touch on #33 as well. |
Yeah, in my efforts in my branch I marked There's also the matter of expanding the Thanks again! (Y'all are so fast at responding, haha). |
Yeah, semver was my intention for this, but I'm more comfortable with making changes to the public API in the 0.x releases than I will be in 1.x releases. If it doesn't break existing games, and minimises any additional burden on new developers, I'll likely be OK with it. |
In retrospect, if existing games leverage the Also, it was my intention to provide very basic serialization / deserialization routines using .NET's XML serializer, which hopefully should allow new developers to onboard a little easier. We'll see how it shakes out, haha. |
Yeah, that sounds good. I'm hesitant to introduce serialisation/deserialisation into Yarn Spinner itself, because it's designed to be a single piece of the puzzle that fits alongside existing elements. Yarn Spinner doesn't and shouldn't care about how you save your variables - it wants you to handle that yourself, in your own way. If you do introduce your own serialisation infrastructure, I strongly suggest making it an example script and keeping it in Unity-space. It's a really good idea to make it easier for new developers! But game developers will likely need to save lots of additional data besides the variables in their dialogue system. If that gets serialised separately, we're merely solving one problem while introducing new ones. (If this was your intention all along: ignore all of the above 😁) |
Ha! Nah that's great direction. I'll ensure that user-facing stuff stays user-facing and sticks around as example code in Unity. Thanks again! |
We've been talking a lot about storing different types in variables in this issue, but this issue is actually about string expansion in lines of Yarn. So I've created a new issue specifically for the variable storage topic at #36 - please continue discussion related to that there! 👍 This issue will remain open until string expansion is sorted. |
#36 is now done; variables can now store strings. This was a pre-requisite for this issue. |
Are there general plans with regards to handling localisation? I know that was another pre-requisite for this issue and I was intending to look in to string expansion more soon, since the variable type stuff just went in. |
I’m hoping to post some notes about the general plan today. Had a chat with Ron Gilbert (!!) about this very topic at GDC. |
That's awesome. Looking forward to reading them~ On 4/2/2016 2:27 PM, Jon Manning wrote:
|
I'm proposing that we add syntax to Yarn that supports this. It would look like this:
Depending on the value of the variables
In this line, the square brackets are delimiters; within these delimiters, a variable name is given. I'm tempted to restrict this syntax to be variables only; the reasoning for this is that if we support arbitrary expressions, that means supporting functions, and if those functions return strings, Yarn has no way to determine what their possible values are, and therefore can't figure out if they need to be localised or not. This restriction can be lifted later, once this problem is solved. I'd like to open this up for discussion. Anyone have any thoughts on how this could be better? |
In terms of my use case, I can't imagine needing more than the ability to expand variables, as I can just store function output in a variable before the line is output and get around the need for any inline function calls. So in the above proposed form, it certainly suits my needs. |
Yes to just variable expansion; heavy computation can be done in custom macro's that are invoked before usage, and that's probably where heavy computation belongs. Being the resident Twine-compatibility buzzkill I checked to see if twine has a variable expansion built in and it seems to use the Stylistically, I used |
My reasoning for using square brackets Additionally, using square braces likens them to their use in print, to represent an inferred or replaced word: "She [said] she hadn't done [the refuelling] yet." |
A temporary solution to those who need this ASAP:
Finally, in the RunLine function, make sure to replace all instances of This way the UI handles the conversion of variables, not the best solution, especially when localization becomes relevant, but it works for now! For example, in my dialog I have
|
Would that be in the ExampleDialogueUI script? Or in the DialogueRunner script, where the abstract class of DialogueUIBehaviour is defined |
@rmill019 The modification by @TheSabotender goes into ExampleDialogueUI.cs |
@Kadelam Thank you. I was able to get it to work. |
Our current project is attempting to be able to call variables in responses as well. By any chance does anybody here know if someone has figured out a quick fix to incorporate this? |
Sorry, what do you mean but call variables in response? |
Just a heads up for everyone, in order to use the function above you also need to add a public variable that references your current Variable Storage script |
This feature shipped in v1.1, so I'm closing this issue now. |
It would be really convenient if variables inside of dialog were replaced with their values. This would allow the dialog to be a lot more dynamic.
Some examples:
"$player_name is pretty cool!" would change to "Samus is pretty cool!"
"You have $gold_in_bank gold in your account" would change to "You have 50 gold in your account".
The text was updated successfully, but these errors were encountered: