DialogueManager.instance.activeConversation is null in the first node?
Posted: Fri Sep 10, 2021 8:47 am
Hello,
I have recently bought Dialogue System and am currently learning to use it. I'm impressed with all the features but I am already running into several issues, probably coming from my misunderstanding of this or that feature, even after RTFM.
The biggest issue I have for now is the fact that during the first node of the conversation (which is on the player side, waiting for an input from the player), I want to be able to show the internal name of the other participant and I can't because I can't access its data, all this because is still null at that time. It is no longer null and therefore becomes usable from the second node, but not during the first one. Here is a little background to explain the problem and my need:
In my game (still in prototyping phase), my characters are all the same at design time, they are generated when starting the level, using scriptable objects describing the identity of each one. When one of them starts a conversation with another, it calls, so far so good, the conversation starts.
However, I also need to access some internal variables of the characters directly from Lua without copying them into the variables space of the Dialogue System because they might change during the conversation and I don't want to have to preemptively expose variables that I may or may not use in a conversation (and to have to do it the other way around when the conversation ends if any of these variables has changed). To this end, I made a few functions to get the values I need directly from the objects, by name. For example, returns one of the three names each character has (that way I can vary depending on the familiarity level between the characters).
Of course, when writing the conversation in the first place, I do not know that a character's internal name is "char_1", that id is calculated automatically at runtime so that it is unique. I only know it is either the actor or the conversant so I need a way to dynamically replace an alias (for example "@you") with the actual id ("char_1") when the conversation takes place. In other words, I write 'Hello [lua(GetString("@you.nickname"))], how are you?' in the very first node ("@you" being the alias for the conversant in this case) and I want it to show to the player, as a choice, "Hello Kay, how are you?" (if the "char_1" character's nickname is "Kay" and Kay is the conversant). But it doesn't work because for that I need the conversation and it is null at that time.
My initial workaround was to call before calling but since I don't know in advance what name they will use during the conversation, this would make me expose at least six names (three per participant) just to be able to use one of them during the very first node. Another workaround would be to create a bogus first node with nothing in it just to let the conversation object be created but frankly that's more a hack than a workaround.
Is there something didn't get correctly and how can I manage to get access to right from the start?
I have a second question, less blocking this one but it would be nice to have... Right now I write in a node to get the value of an internal variable of one of my objects, not using DS's variables at all (because as I said, they may change whenever) but that's a big cumbersome. Ideally, I'd like to write something like (the first '@' meaning "this is a call to GetString() in the program" and the second '@' meaning "this is an alias" but that part is already taken care of, having both symbols be the same allowing me to write such tokens more quickly). Is there a way to do that? My idea would be to have some kind of hook to dynamically replace the '[@' part with '[lua(GetString("' and the ']' part with '"))]', before DS even calls Lua to actually parse the '[]' token and call the functions.
Thanks!
I have recently bought Dialogue System and am currently learning to use it. I'm impressed with all the features but I am already running into several issues, probably coming from my misunderstanding of this or that feature, even after RTFM.
The biggest issue I have for now is the fact that during the first node of the conversation (which is on the player side, waiting for an input from the player), I want to be able to show the internal name of the other participant and I can't because I can't access its data, all this because
Code: Select all
DialogueManager.instance.activeConversation
In my game (still in prototyping phase), my characters are all the same at design time, they are generated when starting the level, using scriptable objects describing the identity of each one. When one of them starts a conversation with another, it calls
Code: Select all
DialogueManager.StartConversation (conv_name, this.transform, other.transform)
However, I also need to access some internal variables of the characters directly from Lua without copying them into the variables space of the Dialogue System because they might change during the conversation and I don't want to have to preemptively expose variables that I may or may not use in a conversation (and to have to do it the other way around when the conversation ends if any of these variables has changed). To this end, I made a few functions to get the values I need directly from the objects, by name. For example,
Code: Select all
GetString ("char_1.nickname")
Of course, when writing the conversation in the first place, I do not know that a character's internal name is "char_1", that id is calculated automatically at runtime so that it is unique. I only know it is either the actor or the conversant so I need a way to dynamically replace an alias (for example "@you") with the actual id ("char_1") when the conversation takes place. In other words, I write 'Hello [lua(GetString("@you.nickname"))], how are you?' in the very first node ("@you" being the alias for the conversant in this case) and I want it to show to the player, as a choice, "Hello Kay, how are you?" (if the "char_1" character's nickname is "Kay" and Kay is the conversant). But it doesn't work because for that I need the conversation and it is null at that time.
My initial workaround was to call
Code: Select all
DialogueLua.SetVariable ("your_nickname", other_character.nickName)
Code: Select all
DialogueManager.StartConversation()
Is there something didn't get correctly and how can I manage to get access to
Code: Select all
DialogueManager.instance.activeConversation
I have a second question, less blocking this one but it would be nice to have... Right now I write
Code: Select all
[lua(GetString("@alias.internal_variable"))]
Code: Select all
[@@alias.internal_variable]
Thanks!