Lua conversation context

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Lua conversation context

Post by tomwilhelm »

Hey, I appreciate that 'thisID' is available as a special variable for lua conditions. Is there a special variable to get the current conversation ID? If not how would you recommend getting the current conversation ID for a dialog entry condition?
Thanks!
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua conversation context

Post by Tony Li »

Hi,

Are you talking about the Conditions field of a dialogue entry?

All SimStatus values are stored in Conversation[X].Dialog[Y], where X is a conversation ID and Y is a dialogue entry ID. So if you check conversation 7, entry 42's SimStatus, it would be Conversation[7].Dialog[42].SimStatus.

"Dialog[Y]" without the Conversation[X] part is an alias for the current conversation's Dialog[] table. So if the current conversation is conversation 7, you can just use Dialog[42].SimStatus. Or, if the current dialogue entry is 42, just Dialog[thisID].SimStatus.

If you need to know the conversation ID in C#, it's DialogueManager.lastConversationID. The title is DialogueManager.lastConversationStarted.
tomwilhelm
Posts: 13
Joined: Sun Jan 24, 2021 6:18 pm

Re: Lua conversation context

Post by tomwilhelm »

Hey Tony,
Thank you for the response. After some investigation I found a way to have the current conversation ID value available during entry conditions and scripts. I added this component to the Dialogue Manager.

Code: Select all

public class PrepareDialogueEntry : MonoBehaviour
{
	public void OnPrepareConversationLine(DialogueEntry entry)
	{
		Lua.Run($"thisConversation = {entry.conversationID}");

	}
}
I with this value was available out of the box like 'thisID' or as a special variable like Variable["ConversationIndex"].
Thanks!
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua conversation context

Post by Tony Li »

Thanks for sharing your solution!
Post Reply