Archaegeo / DualUniverseLuaIssues

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

API to access item stats (both with and without talents) #54

Open matpratta opened 1 year ago

matpratta commented 1 year ago

So the idea here would be adding two new functions: construct.getElementStats(id) and system.getItemStats(id).

They would work in a very similar way to each other, except the construct.getElementStats function would receive a local element id and return the element's stats with any handling talents applied, while system.getItemStats would receive the actual item id and return the base stats for that item.

Those stats would be the same as we can see when we right-click and select "Inspect" on some element: image

Basically, this would match a Lua table like this:

{
  maxThrust = 2160000,
  warmupTime = 8,
  worksInAtmosphere = true,
  worksInSpace = false,
  fuelConsumption = 3981,
  antimatterResistance = 0.4,
  electromagneticResistance = 0.4,
  kinecticResistance = 0.3,
  thermicResistance = 0.3,
  volume: 3355.4,
  mass: 17000,
}

Those values are the base ones (system.getItemStats) but when calling them via construct.getElementStats we should get them corrected with any handling talents (piloting talents could help too, but would probably mean more complexity, so I'm not sure on that one).

This would allow for the creation of in-game item catalogs and even ship design tools, without the need of hardcoding every single element or having to manually input talent values either.

NQ-Ligo commented 1 year ago

At this time, we do not allow players to access talents-related data via Lua.

However, we could consider having an item status property, perhaps as another table field returned by the getItem function or something else.