Page 1 of 1

Setting Actor Field Bit Weird

Posted: Sun Jan 10, 2021 6:50 am
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?

Re: Setting Actor Field Bit Weird

Posted: Sun Jan 10, 2021 9:10 am
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.

Re: Setting Actor Field Bit Weird

Posted: Sun Jan 10, 2021 6:33 pm
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!

Re: Setting Actor Field Bit Weird

Posted: Sun Jan 10, 2021 8:35 pm
by Tony Li
Hi,

Yes. You can add a watch in the Dialogue Editor's Watches tab. Set it to Actor["Geologist"].Location

Re: Setting Actor Field Bit Weird

Posted: Sun Jan 10, 2021 11:24 pm
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

Re: Setting Actor Field Bit Weird

Posted: Mon Jan 11, 2021 10:19 am
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"]

Re: Setting Actor Field Bit Weird

Posted: Mon Jan 11, 2021 5:25 pm
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!

Re: Setting Actor Field Bit Weird

Posted: Mon Jan 11, 2021 7:34 pm
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.