How to properly use DialogueLua.GetStatus() within C# scripts?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

How to properly use DialogueLua.GetStatus() within C# scripts?

Post by sebjschindler »

Hi,

For one of my projects, I'm trying to make an object activate/deactivate depending on the value of a status. In the dialogue database using GetStatus(Actor[], Actor[]) ~= "Met" and SetStatus(Actor[],Actor[]), "Met" works perfectly fine, yet translating this into a C# script appears very tricky. I notice that there are functions that can be accessed like DialogueLua.GetStatus() and DialogueLua.SetStatus(), but the parameters require LuaTables and I have been unable to find a way to convert Actor tables to LuaTables.

At the end of the day I simply want to be able to check Statuses through C#, so any help or pointers are greatly appreciated!
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to properly use DialogueLua.GetStatus() within C# scripts?

Post by Tony Li »

Hi,

Write a little utility function:

Code: Select all

public string GetActorStatus(string actorName1, string actorName2)
{
    string actorIndex1 = DialogueLua.StringToTableIndex(actorName1);
    string actorIndex2 = DialogueLua.StringToTableIndex(actorName2);
    return Lua.Run($"return GetStatus(Actor['{actorIndex1}'], Actor['{actorIndex2}'])").asString;
}
Then you can use it like this:

Code: Select all

if (GetActorStatus("Player", "Private Hart") ~= "Met")
{ ... }
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: How to properly use DialogueLua.GetStatus() within C# scripts?

Post by sebjschindler »

Got it, thanks Tony! I'll try it out and reply here if I can't make it work the way I want.
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: How to properly use DialogueLua.GetStatus() within C# scripts?

Post by sebjschindler »

Oh, and thanks so much for the really quick reply and how clear and concise your explanation was! I'm learning more and more each day I use this thing, haha.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to properly use DialogueLua.GetStatus() within C# scripts?

Post by Tony Li »

Happy to help!
Post Reply