Setting Actor fields not working/saving
Posted: Mon Jan 01, 2018 11:41 pm
Preemptively, I apologize if this ends up being word salad, but I'm at a bit of a loss in a couple aspects.
This may be partially me not understanding the database as well as needed, but I need to be able to dynamically create new Actors, and update Actor fields (name, description, as well as any other custom fields) because of a character customization mechanic.
Currently, I'm using the DialogueDatabase.actors.Add(Actor name) function to add a new Actor, which works on its own, and it shows up in the dialogue editor as it should. Using the Actor(Actor sourceActor) constructor works mostly ok (outside of problems I'll get to shortly). However, using the Actor() constructor allows me to edit the new Actor's id, but gives me a NullReference if I try to edit the Name, add additional Fields, or quite frankly do anything else with it outside of adding it to the database, which does work. Am I missing something with a blank Actor object?
As for using a copied Actor, like I mentioned before, the .Add function works. The new Actor appears immediately in the Dialogue Editor, and leaving play mode keeps this new object in the DE as well. My confusion is that field edits appear to work in play mode, but do not visually update in the DE, nor do they save after leaving play mode.
This code properly prints out "10", but does not save after leaving play mode, and does not visually update the Dialogue Editor at any point. (Experience shows 0 at all times even after the SetActorField function) At what point is my understanding lacking here?
Thank you in advance.
This may be partially me not understanding the database as well as needed, but I need to be able to dynamically create new Actors, and update Actor fields (name, description, as well as any other custom fields) because of a character customization mechanic.
Currently, I'm using the DialogueDatabase.actors.Add(Actor name) function to add a new Actor, which works on its own, and it shows up in the dialogue editor as it should. Using the Actor(Actor sourceActor) constructor works mostly ok (outside of problems I'll get to shortly). However, using the Actor() constructor allows me to edit the new Actor's id, but gives me a NullReference if I try to edit the Name, add additional Fields, or quite frankly do anything else with it outside of adding it to the database, which does work. Am I missing something with a blank Actor object?
As for using a copied Actor, like I mentioned before, the .Add function works. The new Actor appears immediately in the Dialogue Editor, and leaving play mode keeps this new object in the DE as well. My confusion is that field edits appear to work in play mode, but do not visually update in the DE, nor do they save after leaving play mode.
Code: Select all
Actor newNPC = new Actor(database.GetActor("Monster_Base"));
newNPC.id = database.actors.Count + 1;
newNPC.Name = "Brent";
database.actors.Add (newNPC);
DialogueLua.SetActorField (database.actors[database.actors.Count - 1].Name, "Experience", 10);
print (DialogueLua.GetActorField("Brent", "Experience").AsString);
Thank you in advance.