-
January 26th, 2023, 10:31 #11
Use relative DB paths - info on DB paths here: https://fantasygroundsunity.atlassia...Database-Paths
So, you could use DB.getValue(nodeWin, "...string.number", "") would go two steps up in the DB hierarchy from nodeWin (the first "." is the same location as nodeWin) and then proceeds to the child string and from there returns the value of the child field called "number".Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 26th, 2023, 11:14 #12
- Join Date
- May 2020
- Posts
- 34
Thx a lot, will that try back at home!
-
January 26th, 2023, 14:43 #13
- Join Date
- Jun 2020
- Posts
- 534
Hi Moon Wizard! This is a great theory and I think you are spot on here. I see a lot of slowness currently when using the API to copy large DB lists of DB nodes and children around, and perhaps this will be a great speed improvement. I have a few concerns though. Namely, there are a lot of unofficial rulesets (on the Forge) etc. that are probably not aware of such a change, and this would definitely break all of those rulesets. Additionally, we have a release coming up for Cyberpunk RED, which is coming along nicely, but we will need to do a lot of refactoring (immediately after release preferably) and then a full regression test, to ensure issues do not crop up as a result. It is a lot of work (and we are not full SW employees).
If what I understand here is correct, each dbnode reference (a userdata object) is loading dependencies needed to be able to do those API calls, probably lots of XML libraries and such. Now, I am not a Lua expert by any means, but perhaps there is another way to do this refactor while ensuring cross-compatibility with older rulesets.
Would something like this be possible?
- Keep dbnode references a userdata object with .getChild, .getChildren, .getValue, and .setValue
- Refactor the underlying userdata object (C++ I am assuming? C#?) to instead call a singleton that is managed by the application. The singleton is then responsible for loading all the XML packages/libraries needed, and then calls those needed for each call, with the values as specified by the userdata object.
The idea here is then just one singleton class/userdata object is instantiated for the whole application that is responsible for doing XML lookups, setting values, etc., and each dbnode just points to that singleton wrapper.
Again, apologies if this was already considered or is just not possible, I have never edited an application's Lua script engine, and my knowledge of the Lua interpreter is pretty limited.
-
January 26th, 2023, 19:57 #14
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
On the @Trenloe/@Elawyn discussion, one note is that the new method will be much more performant than the concatenation method, because you have less API calls that have to be translated between Lua to the core engine.
nodeWin.GetParent().GetParent().GetChild("string") .getValue("number") = 4 API calls
DB.getValue(nodeWin, "...string.number", "") = 1 API call.
Regards,
JPG
-
January 26th, 2023, 20:08 #15
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
@seansps,
API references are actually tied to directly to each individual object, so that there is context for when an API is called. If it was a general function, there would be no context.
Also, all the APIs have to be registered to each object in order to be linked to an object in order for Lua to work which is part of the overhead.
I’ll definitely be looking at ways to possibly minimize disruption once I can verify whether the theory that performance will be affected is tested with a special client with the databasenode rewritten.
Thanks,
JPG
-
January 26th, 2023, 22:19 #16
- Join Date
- May 2020
- Posts
- 34
Thank you and yes, it seems "smoother" and i hope your work will be fruitful! I tested the db. Method for string calls and number calls, both are working (for me such Things are exiting, sorry ) I am relieved so far. My nodeWin.getPath() i have struggle with but i will think about and if i unterstand the timeline right, its Not an instant encounter.
-
January 26th, 2023, 22:50 #17
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
Most single-call functions can usually be rewritten pretty easily nodeVar.fn(...) -> DB.fn(nodeVar, ...)
The exception is DB.setValue which requires a type parameter, and chained calls which end up having to be nested.
Also, most chained calls are of the form nodeVar.getParent().getParent()... or nodeVar.getChild(...).getChild(...). These are faster to implement as paths using the dots for going up/down tree.
Regards,
JPG
-
January 27th, 2023, 04:15 #18
- Join Date
- Jun 2020
- Posts
- 534
Thanks for the response! That’s too bad if it can’t work with a singleton…
I believe that when multiple instances of a userdata object are created in a Lua script, with pointers to a singleton, then they’d all just reference the same underlying object in memory. If the dbnode objects pointed to a singleton object it should only consume memory once, regardless of how many references to it exist in the Lua script (at least for the API portion.)
But that’s just my theory. I’ve never implemented anything like this.Last edited by seansps; January 27th, 2023 at 04:42. Reason: Edit for clarity
-
January 29th, 2023, 08:46 #19
How would you rewrite the second line here?
Code:local nodeRoll = window.getDatabaseNode(); local nodeChar = nodeRoll.getParent().getParent();
-
January 29th, 2023, 09:00 #20
local nodeChar = DB.getChild(nodeRoll, "...");
Dominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks