Archaegeo / DualUniverseLuaIssues

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

Please add support for lift and brakes on `construct.getMaxThrustAlongAxis` #55

Open matpratta opened 1 year ago

matpratta commented 1 year ago

I'm not sure if this fits as a bug, but basically, if you call construct.getMaxThrustAlongAxis you will not get the right values for lift and no values at all for brakes. For example, the script below should get all thrust, brake and lift stats for a ship:

local pwrAtmoThrust = construct.getMaxThrustAlongAxis('atmospheric_engine', construct.getOrientationForward())
local pwrSpaceThrust = construct.getMaxThrustAlongAxis('space_engine', construct.getOrientationForward())
local pwrAtmoBrake = construct.getMaxThrustAlongAxis('atmospheric_brake')
local pwrSpaceBrake = construct.getMaxThrustAlongAxis('space_brake')
local pwrLiftHigh = construct.getMaxThrustAlongAxis('airfoil', construct.getOrientationUp())
local pwrLiftLow = construct.getMaxThrustAlongAxis('ground', construct.getOrientationUp())

system.print('AT: ' .. table.concat(pwrAtmoThrust, ', '))
system.print('ST: ' .. table.concat(pwrSpaceThrust, ', '))
system.print('AB: ' .. table.concat(pwrAtmoBrake, ', '))
system.print('SB: ' .. table.concat(pwrSpaceBrake, ', '))
system.print('LH: ' .. table.concat(pwrLiftHigh, ', '))
system.print('LL: ' .. table.concat(pwrLiftLow, ', '))

The values for atmo and space thrust work correctly, same as low-altitude lift. When trying to retrieve values for high-altitude lift (airfoils) the values returned are zero. The same applies for brakes, no matter what I use as the second argument (axis).

This problems gets worse if I try to use construct.getMaxBrake(), as not only that function only returns a single number value, which we don't know whether it's space or atmo brake value, but it also seems to return zero when ran from a Programming Board with the ship not moving.

An ideal solution would be making so that the values returned by the function matched what's received from the Build Helper, including brakes and high-altitude lift power. Another thing that could help is described on #54, but basically having an API where we can query each of the individual element's stats, though it's not ideal as it's probably going to be very laggy...

Thanks!

NQ-Ligo commented 1 year ago

construct.getMaxBrake() have been implemented with the idea of giving the maximum available braking force in real time. This is not a problem. And besides considering that the braking force depends on the velocity of your construct, it returns 0 when your ship is static.

However, regarding construct.getMaxThrustAlongAxis(), I might consider adding wings in the calculation if the tags match.

Brakes are a little different, they don't have a specific thrust direction, they are applied in the opposite direction of your construct's velocity, so they can't be added into the calculation.

matpratta commented 1 year ago

@NQ-Ligo makes sense! Is there any chance of having something to get the overall max brake capability (both atmo and space values) similar to construct.getMaxThrustAlongAxis()? Even if the actual value depends on the current velocity, having an way of getting the maximum limit of the brakes both in space and atmo would be nice for anyone writing scripts that involve reentry, be it a flight script or something like an space elevator...