Page 1 of 1

Newbie trouble with lua vars and continuing conversations

Posted: Fri May 24, 2019 5:35 pm
by Senua
I want to have an npc which as the player interacts, does something else, returns to interact, and picks up where they left off in the dialogue?/conversation? I tried laying them all out [there are about 20 different statements with 2 to 3 menu options for the player but of course some of these are never seen depending on the options the player chooses] in one Conversation and the layout was great, but then the player simply worked through the whole entire scene's worth of dialogue without being able to move away. If they moved away, it restarted when triggered again of course.

So I tried the RememberCurrentDialogueEntry.cs script, but while I got the debug lines, it never saved anything. I tried putting in the variables and initializing them in case they couldnt be created, but they never changed.
So I tried laying out my dialogue as individual conversations [aka 20 of them] -- one npc line with one set of options. I made a curconvo var to keep track, assuming I could use the script field on a menu option child to set the curconvo to the next linked convo id. The logic appeared to work, as I could hardcode the curconvo to whatever id I wanted the dialogue would jump to [because I had set conditions for that var on the convos] and start there. And yet again, when running the scene, the variable never changed even though I was setting it.

This is all during one running of a scene -- I'm not switching scenes or restarting. I just want to be able to walk away from the npc and come back and jump into the correct point of my conversation based on where I left off.
I've reviewed the demo scene and I feel like I'm doing the same setup as used for killing enemies and checking that value. :?

Re: Newbie trouble with lua vars and continuing conversations

Posted: Fri May 24, 2019 8:57 pm
by Tony Li
Hi,

Use a variable, and the Conditions and Script field in a single conversation. (However, if you want to use multiple conversations you can use cross-conversation links.)

Here's an example scene:

ContinuingConversationExample_2019-05-24.unitypackage

To set it up, in the Variables section I created a Number variable named "Times_Talked_To_Hart" whose value starts at zero. (Hart is the NPC.)

Image

The conversation looks like this:

Image

The <START> node links to four possible conversation openings.

The Dialogue System will choose the first opening if Times_Talked_To_Hart is zero. If so, it will increment Times_Talked_To_Hart. To set that up, I clicked the "..." buttons next to Conditions and Script and used the dropdowns.

The Dialogue System will choose the second opening if Times_Talked_To_Hart is 1, and so on.

---

(Side note: RememberCurrentDialogueEntry serves an entirely different purpose, and it only works in conjunction with the save system, so you'd have to have the save system set up, too. RememberCurrentDialogueEntry -- and its newer iteration, ConversationStateSaver -- remembers in saved games if you saved the game while a conversation was active. When you load a saved game, it restarts the conversation at the same place.)

--

If I completely misunderstood, and you want the player to be able to stop the conversation at any point and later resume at that point, please let me know. It's possible but awkward to do using the technique above. But a small script will take care of it.

Re: Newbie trouble with lua vars and continuing conversations

Posted: Fri May 24, 2019 9:39 pm
by Senua
Wow, thank you so much!
I came back to update that I was able to do it with multiple conversations linked and using my curconvo var, but that I had foolishly forgotten to set the link to the conversation to point to the first dialogue, but instead had it to the 'start' or blank item and then I managed to change my conversation on my actor script in the scene to the wrong one while I was testing . . . very silly of me, just in a panic. But now, with this, I have multiple options since this does it in one conversation! This is lovely, and I'm so glad to have the link to the update to rememberconvo [for future ref]!
Thank you again, just incredible!

Re: Newbie trouble with lua vars and continuing conversations

Posted: Fri May 24, 2019 9:41 pm
by Tony Li
Happy to help! I'm glad you got it working your way, too.