Page 1 of 1

Best way to look for immutable fields: database or lua environment?

Posted: Sat May 02, 2020 3:35 pm
by _marc
Hi Tony,

I'm wondering what's the best choice to access the field of an item (or actor...), in terms of performances. I'm talking about a value that never changes (which is immutable, always the same between the database and the Lua environment). Is it better to look for the value in the database or the Lua environment? Or in other words:

DialogueManager.masterDatabase.GetItem(id).AssignedField("title").value;
or
DialogueSystem.DialogueLua.GetItemField("item", "field");

Best regards,

Marc

Re: Best way to look for immutable fields: database or lua environment?

Posted: Sat May 02, 2020 11:49 pm
by Tony Li
They're actually comparable in performance. DialogueLua uses optimized table lookups versus regular Lua expressions. So feel free to use whichever one you prefer. If you use DialogueManager.masterDatabase.GetItem(), use LookupValue. Example:

Code: Select all

string s = DialogueManager.masterDatabase.GetItem("Name").LookupValue("title");

Re: Best way to look for immutable fields: database or lua environment?

Posted: Mon May 04, 2020 5:18 am
by _marc
Thank you for the information!
Have a nice day : )

Re: Best way to look for immutable fields: database or lua environment?

Posted: Mon May 04, 2020 8:58 am
by Tony Li
Glad to help!