Page 1 of 1

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

Posted: Mon Jul 05, 2021 2:57 pm
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!

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

Posted: Mon Jul 05, 2021 3:23 pm
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")
{ ... }

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

Posted: Mon Jul 05, 2021 9:40 pm
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.

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

Posted: Mon Jul 05, 2021 9:47 pm
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.

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

Posted: Mon Jul 05, 2021 10:02 pm
by Tony Li
Happy to help!