Archaegeo / DualUniverseLuaIssues

DualUniverse LUA Issue Tracking
GNU General Public License v3.0
5 stars 0 forks source link

Direct Access To Element Objects #34

Open samdeane opened 3 years ago

samdeane commented 3 years ago

(originally posted here)

It seems fairly crazy that we can iterate the core to get basic information about the id, type, etc of each element (using getElementIdList(), getElementNameById, ...), but we can't get the actual element objects that way. We have to link them, then access the named variables connected with each link. If we want to iterate all linked elements, we have to build our own table and write manual code to add the elements to it. That doesn't make a lot of sense!

I would suggest deprecating most of the existing API, and just having two element related methods:

All other properties can then be read from the existing element API:

A few element API additions would be good:

samdeane commented 3 years ago

This could also be done with an asynchronous API, if it helped with managing back-end database access.

Eg: withElementById(uid, callback), where callback is a Lua function to call and pass the element object to.

EasternGamer commented 3 years ago

https://board.dualthegame.com/index.php?/topic/23678-lua-suggestion-general-function-structure-camera-data/&tab=comments#comment-171701

Deckard basically answered it here for me... sort of. Your's is a little different approach.

samdeane commented 3 years ago

That's a great post, thanks. I attempted to get us doing something similar last year, but it didn't really get much traction!

I am pleased to hear that Deckard says they have plans in that direction, though I'm worried that (a) I might not still be playing by the time they come to fruition, and (b) the game might not make it that far.

NQ-Ligo commented 2 years ago

Hi there !

I can confirm you that, that kind of change is planed and in progress. We're thinking about which approach could be the best on that. However it will come anyway on linked elements too, to get data like getName for the example.