Been searching the forums for some info on this but struggling a bit.
I need to get a special menu to open at the end of certain conversations. What would be the best way to go about this? Sequence commands seem to still run within the conversation, as do Lua scripts. Is there anyway to flag which conversations will open that menu when they finish?
I was hoping I would be able to add an empty conversation block with nothing but the Lua script to toggle the menu at the end of the conversation but that seems to leave an empty panel.
The only other way I can think of is to combine the OnConversationEnd with some kind of bool check via Lua to see if this particular conversation will be triggering the menu at the end. Just not sure if that's the best course of action.
Sorry if I'm overlooking something and thanks in advance.
Using OnConversationEnd only on specific conversations?
Re: Using OnConversationEnd only on specific conversations?
Ok after tinkering for a couple more hours, I figured out what might be the smoothest way to do this. Please take this with a grain of salt because I basically just bashed my head against it until it worked!
I went ahead and added a variable to the template in the database called "OpenMenu". I can then set that through the script field in a conversation node though this:
Along with this, I added a DialogueSystemTrigger component directly onto the DialogueManager with the OnConversationEnd trigger.
Under the conditions for it, I added Lua
so that it only triggers the OnConversationEnd method if the particular conversation we're in happened to have set the variable to true.
Under the Actions, I used OnExecute() to call an event in a script which I attached it directly onto the DialogueManager as well and all it basically does is
I still need to figure out if I need to manually reset that variable every time but leaving this here in case anyone else runs into it while trying to do something similar. Please feel free to correct me if there's a better or alternative way to do this!
I went ahead and added a variable to the template in the database called "OpenMenu". I can then set that through the script field in a conversation node though this:
Code: Select all
Variable["OpenMenu"] = true
Under the conditions for it, I added Lua
Code: Select all
Variable["OpenMenu"] == true
Under the Actions, I used OnExecute() to call an event in a script which I attached it directly onto the DialogueManager as well and all it basically does is
Code: Select all
public void ToggleMenu(){
//Code here to do whatever on conversation end and variable set to true.
}
Re: Using OnConversationEnd only on specific conversations?
Hi,
Yes, you'll want to reset the variable. You can do it in the same Dialogue System Trigger. Select Add Action > Run Lua Code. Then set the Lua code to:
That's a fine solution. Any other solutions I'd suggest would be fairly similar in complexity. Below is an alternate suggestion. Yours is just as good, though. I'm just providing it as an alternative.
Yes, you'll want to reset the variable. You can do it in the same Dialogue System Trigger. Select Add Action > Run Lua Code. Then set the Lua code to:
Code: Select all
Variable["OpenMenu"] = false
- Remove the variable and the Dialogue System Trigger that's set to OnConversationEnd.
- In the script with ToggleMenu, add a conversation title string variable so you can select which conversation opens the menu. Also add an OnConversationEnd method that checks if this conversation just ended.
Code: Select all
[ConversationPopup] public string conversationToShowMenuAtEnd;
void OnConversationEnd(Transform actor)
{
if (DialogueManager.lastConversationStarted == conversationToShowMenuAtEnd)
{
ToggleMenu();
}
}
Re: Using OnConversationEnd only on specific conversations?
Got it thanks!Tony Li wrote: ↑Sat Sep 26, 2020 9:42 pm Hi,
Yes, you'll want to reset the variable. You can do it in the same Dialogue System Trigger. Select Add Action > Run Lua Code. Then set the Lua code to:That's a fine solution. Any other solutions I'd suggest would be fairly similar in complexity. Below is an alternate suggestion. Yours is just as good, though. I'm just providing it as an alternative.Code: Select all
Variable["OpenMenu"] = false
- Remove the variable and the Dialogue System Trigger that's set to OnConversationEnd.
- In the script with ToggleMenu, add a conversation title string variable so you can select which conversation opens the menu. Also add an OnConversationEnd method that checks if this conversation just ended.
Code: Select all
[ConversationPopup] public string conversationToShowMenuAtEnd; void OnConversationEnd(Transform actor) { if (DialogueManager.lastConversationStarted == conversationToShowMenuAtEnd) { ToggleMenu(); } }
Re: Using OnConversationEnd only on specific conversations?
Sorry I have one last question!
What's the difference between putting the variable in the templates vs dropping it into the Variables tab instead? I'm using multiple databases and can't seem to get the template to display the variable through the Lua wizard, but it does work when I put it in the Variables section of the MasterDatabase instead.
Re: Using OnConversationEnd only on specific conversations?
Hi,
If you're using multiple databases, make sure you've read Working With Multiple Databases.
If you're using the Lua wizard while editing a dialogue database, it will only show variables in the database that you're editing.
However, you can sync the variables from a primary database (typically assigned to the Dialogue Manager's Initial Database field) to your other databases so they're available in all databases.
You shouldn't need to adjust the definition of Variables in the Templates section of the Dialogue Editor window.
If you're using multiple databases, make sure you've read Working With Multiple Databases.
If you're using the Lua wizard while editing a dialogue database, it will only show variables in the database that you're editing.
However, you can sync the variables from a primary database (typically assigned to the Dialogue Manager's Initial Database field) to your other databases so they're available in all databases.
You shouldn't need to adjust the definition of Variables in the Templates section of the Dialogue Editor window.