Page 1 of 1

Lua conversation context

Posted: Thu Dec 22, 2022 1:00 am
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!

Re: Lua conversation context

Posted: Thu Dec 22, 2022 8:24 am
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.

Re: Lua conversation context

Posted: Wed Jan 04, 2023 6:55 pm
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!

Re: Lua conversation context

Posted: Wed Jan 04, 2023 7:02 pm
by Tony Li
Thanks for sharing your solution!