Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct Access To Element Objects #34

Open
samdeane opened this issue Oct 18, 2021 · 4 comments
Open

Direct Access To Element Objects #34

samdeane opened this issue Oct 18, 2021 · 4 comments
Labels
enhancement New feature or request NQ-COMMENTED This issue or pull request already exists

Comments

@samdeane
Copy link

(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:

  • getElementIdList() -- return a list of the ids of all elements in this core
  • getElementById(uid) -- return the element object for the given element

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

  • getElementClass()
  • getHitPoints()
  • getMaxHitPoints()
  • getMass()
    etc...

A few element API additions would be good:

  • getName()
  • setName(newName)
  • getSize() -- return the size (xs, s, m, l, xl)
  • getPosition() -- position in construct local coordinates
  • getOrientation() -- orientation in construct local coordinates
@samdeane
Copy link
Author

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
Copy link

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
Copy link
Author

samdeane commented Oct 19, 2021

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.

@Archaegeo Archaegeo added the enhancement New feature or request label Apr 26, 2022
@NQ-Ligo
Copy link

NQ-Ligo commented Apr 26, 2022

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.

@Archaegeo Archaegeo added the NQ-COMMENTED This issue or pull request already exists label Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NQ-COMMENTED This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants