Page 1 of 1

Using Conversant and Actor to get fields from actors.

Posted: Wed Dec 20, 2017 12:26 pm
by fandrfa
I have a generic conversation template which I'm planning to use for most of my NPCs.
It handles some things that are general for almost every NPC. For example there are some default entries with conditions that check whether the Player has already talk to NPC or not, what is NPC's attitude towards the Player etc.

For Dialogue Text I use stuff like [lua( Actor[Variable['Conversant']].Name)], for conditions I use Actor[Variable["Conversant"]].HasBeenIntroduced == false etc

Using Conversant and Player instead of actors' names allows me to copy this generic conversation and simply change conversant without touching conditions / scripts.

I tried this approach and it worked - I made a game object "Witch" with Conversation Trigger, I dragged Player's and Witch's transforms on the Trigger (Player and Conversant fields) and everything works.

Now I tried to display her name as "Wendy the Witch", and I couldn't.

First, I tried to use "Display Name". I set it to "Wendy The Witch" and get this error.
Dialogue System: Lua code 'return (Actor[Variable["Conversant"]].HasBeenIntroduced == true) and (Actor["NPC"].NewVisit == false)' threw exception 'Lookup of field 'HasBeenIntroduced' in the table element failed because the table element itself isn't in the table.'
I renamed the game object to "Wendy The Witch", but it didn't help.

Ok, I disabled "Use Display Name" and renamed the actor to "Wendy The Witch" and also renamed the game object to "Wendy The Witch". And it also doesn't work.

Then I renamed the actor to "Wendy_The_Witch" and it worked just fine. Of course, I can't use this name in the game.

So, I can't see a way to use the generic stuff like Actor[Variable["Conversant"]] and to use the Display Name or the name with spaces at the same time.

Maybe I am missing something?

Also, is there any way to group actors? Something like Castle/King, Castle/Guard, Lair/Dragon, Lair/Guard etc (like with conversations). I tried to use it this way and it almost worked: https://ibb.co/gxRWqR
So, it would be nice to group actors via their names and to use Display Name as their actual name.

Re: Using Conversant and Actor to get fields from actors.

Posted: Wed Dec 20, 2017 1:34 pm
by Tony Li
The upcoming version 1.7.7 (being released later today), makes two new variables available:
  • Variable["ActorIndex"]
  • Variable["ConversantIndex"]
So Variable["Conversant"] will be "Wendy the Witch" (the Display Name), and Variable["ConversantIndex"] will be "Witch" (the Lua table-compatible Name).

It usually takes 3-7 business days to appear on the Unity Asset Store, but you can PM me your Unity Asset Store invoice number for access to the Pixel Crushers customer download site where you can download it later today.

You should also be able to group Names. So a Name of "[1] Patriots/Witch" should work in dropdowns, and Variable["ConversantIndex"] will be something like "_1__Patriots_Witch" to make it correspond to the Actor[] table's value.