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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
_marc
Posts: 69
Joined: Mon Nov 05, 2018 5:44 am

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

Post 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
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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");
_marc
Posts: 69
Joined: Mon Nov 05, 2018 5:44 am

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

Post by _marc »

Thank you for the information!
Have a nice day : )
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply