Hello there.
I seem to be having issues getting an actor field in my C# script via DialogueLua.GetActorField.
This is strange for me, because I am able to get another field from the same actor in the same area of script.
In this script, I attempt to get an actor's "Attack" power.
As you can see by the middle Debug.Logs, I read out the actor's name, "Health" field, and their "damageAmount" which is actually their "Attack" field.
The console output is shown below.
This is what the actor's fields looks like. You can verify that the proper name is used because not only is the name printed out in the above log, but their health field was properly printed out.
These values were set in-editor prior to runtime:
Please let me know if there is anything I am missing.
Thank you very much!
Justin
Unable to get actor field.
Re: Unable to get actor field.
I believe I have a lead, and that I forgot to mention that I am using 3 separate databases in my turn-based battle system (that uses the dialogue system).
The Health field was appearing properly because I had called DialogueLua.SetActorField(); on it somewhere else in code for testing. When I remove the DialogueLua.SetActorField() for the Health field, it no longer reads properly.
I am guessing that this is because the database that DialogueLua.GetActorField() refers to is the "initial database" set in the current scene's DialogueSystemController. I did think this was the case because I was previously receiving the actor's health property before.
How might I easily get an actor field's runtime values from a specific database?
The Health field was appearing properly because I had called DialogueLua.SetActorField(); on it somewhere else in code for testing. When I remove the DialogueLua.SetActorField() for the Health field, it no longer reads properly.
I am guessing that this is because the database that DialogueLua.GetActorField() refers to is the "initial database" set in the current scene's DialogueSystemController. I did think this was the case because I was previously receiving the actor's health property before.
How might I easily get an actor field's runtime values from a specific database?
Re: Unable to get actor field.
Hi Justin,
If you want to be able to get and set field values at runtime, you'll need to tell the Dialogue System to add the database to the runtime Lua environment. Use the DialogueManager.AddDatabase() C# method or an Extra Databases component to do this.
If you only want to read data from the database, you only need a reference to the database. Then find the actor and read its fields directly from the database instead of accessing Lua. Example:
If you want to be able to get and set field values at runtime, you'll need to tell the Dialogue System to add the database to the runtime Lua environment. Use the DialogueManager.AddDatabase() C# method or an Extra Databases component to do this.
If you only want to read data from the database, you only need a reference to the database. Then find the actor and read its fields directly from the database instead of accessing Lua. Example:
Code: Select all
public DialogueDatabase anotherDatabase; // Assume it's assigned in the inspector.
...
Actor actor = anotherDatabase.GetActor("Enemy1");
int damageAmount = actor.LookupInt("Attack");
Re: Unable to get actor field.
Hi Tony,
Thank you very much. That was a quicker reply than I expected!
I was unaware of the Extra Databases component, and it looks like a simpler solution than what I was about to try.
I just added the Extra Databases component to my battle manager, as well as references to my enemy and friendly party databases. It worked like a charm!
Thanks,
Justin
Thank you very much. That was a quicker reply than I expected!
I was unaware of the Extra Databases component, and it looks like a simpler solution than what I was about to try.
I just added the Extra Databases component to my battle manager, as well as references to my enemy and friendly party databases. It worked like a charm!
Thanks,
Justin
Re: Unable to get actor field.
Great! Glad I could help.