Announcements, support questions, and discussion for the Dialogue System.
OddMan2
Posts: 29 Joined: Fri Feb 11, 2022 11:14 am
Post
by OddMan2 » Thu Feb 24, 2022 3:42 pm
Hello,
i am trying to update a custom field i created on items:
the field is a Bool, called "InInventory"
the code is in a script field during a normal conversation
The debug log says the script is being executed "Dialogue System: Lua(Item["Letter"].InInventory = true)"
The value in the database never changes, what am i doing wrong?
to add more information:
i use this "InInventory" field to check if the item is in the player's inventory.
Code: Select all
foreach (var item in DialogueManager.masterDatabase.items)
{
if (item.IsItem)
{
if (item.AssignedField("InInventory").value == "True")
[ . . . ]
Tony Li
Posts: 22149 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Thu Feb 24, 2022 4:01 pm
Hi,
The database is read-only at design time. Changes occur in the Lua environment. If you're playing in the Unity editor, you can watch the changes in the Dialogue Editor's Watches tab.
To check the value in C# code:
Code: Select all
if (DialogueLua.GetItemField("Letter", "InInventory").asBool) { ... }
To check it in Lua, such as in a dialogue entry node's Conditions field:
Conditions : Item["Letter"].InInventory == true
OddMan2
Posts: 29 Joined: Fri Feb 11, 2022 11:14 am
Post
by OddMan2 » Thu Feb 24, 2022 4:27 pm
Thank you very much tony, your responses are always fast and on point.
I updated my code and it works!