Page 1 of 1

Iterate over actors in C#?

Posted: Wed Oct 02, 2019 10:30 am
by Raelyr
Kind of a weird question, but is there a way to fetch the list of actors and their display names from the dialogue database to use in C#? For example, let's say there's a game feature where you can choose or set the display name (or 'nickname') of NPCs you encounter, and then take or collect 'notes' on them for later use - uh, like a phone book! The C# script managing the phone book may need to check all the nicknames you set via dialogue.

Re: Iterate over actors in C#?

Posted: Wed Oct 02, 2019 1:16 pm
by Tony Li
Hi,

Sure:

Code: Select all

foreach (var actor in DialogueManager.masterDatabase.actors)
{
    Debug.Log(actor.Name + " aka " + DialogueLua.GetActorField(actor.Name, "Display Name").asString);
}

Re: Iterate over actors in C#?

Posted: Wed Oct 02, 2019 3:42 pm
by Raelyr
Thanks Tony! I appreciate you.

Re: Iterate over actors in C#?

Posted: Wed Oct 02, 2019 3:46 pm
by Tony Li
Happy to help!