Setting Actor Field Bit Weird

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Setting Actor Field Bit Weird

Post by Mackerel_Sky »

Hi Tony,

Just have an issue regarding some additional functionality I have been trying to program:

I'm currently working on an NPC spawner that will spawn some people around points of interest and have them say some appropriate lines. To do so, I've updated the NPC template to remove the Locations field and replaced it with a text Location like so:

Image

In the spawner, I set the location field like this:

Code: Select all

            GameObject researcherObject = GameObject.Instantiate(researchers[spawner], transform.position, transform.rotation);
            DialogueLua.SetActorField(researcherObject.name, "Location", locationType);
            Debug.Log(DialogueLua.GetActorField(researcherObject.name, "Location"));
        }
    } 
   
The Debug.Log gives me

Code: Select all

PixelCrushers.DialogueSystem.Lua+Result
UnityEngine.Debug:Log (object)
ResearcherSpawner:Start () (at Assets/Scripts/NPCs/Dialogue/ResearcherSpawner.cs:46)
The gameObjects are all named the same as their Actors in the database. I tried setting a watch for the Actor variables but I couldn't find an option to do so. Using the Info Debug level also doesn't really give me an answer. Any ideas?
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting Actor Field Bit Weird

Post by Tony Li »

Hi,

Instead of this:

Code: Select all

Debug.Log(DialogueLua.GetActorField(researcherObject.name, "Location"));
use this:

Code: Select all

Debug.Log(DialogueLua.GetActorField(researcherObject.name, "Location").asString);
Fields and variables in the Dialogue System have dynamic type, which means they can be returned as a string, int, float, bool, etc. You just need to specify how you want the value.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Setting Actor Field Bit Weird

Post by Mackerel_Sky »

Hey Tony,

Thanks for the fix. I can confirm that the console logs the correct Location as expected, but the relevant condition doesn't seem to want to work in the conversation:

Image

Image

Is there some way to set a watch on the relevant actor so I can see what's going on?

Thanks!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting Actor Field Bit Weird

Post by Tony Li »

Hi,

Yes. You can add a watch in the Dialogue Editor's Watches tab. Set it to Actor["Geologist"].Location
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Setting Actor Field Bit Weird

Post by Mackerel_Sky »

Image

Not sure if I am doing this correctly - refreshing these watches aren't giving me anything. Perhaps there's something wrong with how the template was modified?

Image
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting Actor Field Bit Weird

Post by Tony Li »

Hi,

Are the Location fields set on the Geologist and Ecologist actors? Maybe they just happen to be blank?

Do those actors exist in the active database? To confirm this, add a Lua Console component to the scene. While playing, press ~+L to open the Lua Console. Enter:

Code: Select all

return Actor
This will return a list of all actors in memory. To list the fields of the Geologist, enter:

Code: Select all

return Actor["Geologist"]
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Setting Actor Field Bit Weird

Post by Mackerel_Sky »

Hey Tony,

Figured it out! The spawner instantiates copies of a prefab, so the gameObject.name appended (Clone) to the end. I got rid of it and the system works as intended. Thanks for your help!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting Actor Field Bit Weird

Post by Tony Li »

Great! BTW, you might be able to use a Dialogue Actor component to specify actor names. I'm not sure if that's helpful, but I thought I'd mention it.
Post Reply