Jump to content

[Lua] Automatic extend/retract Landing Gear


_MOHAPX_

Recommended Posts

You need telemeter.

--add item telemeter to bottom ship
--connect telemeter to seat
--rename slot in control unit editor to "telemeter"

--add to system.update()

--Auto extend/retract gear
local speed = math.floor(vec3(core.getWorldVelocity()):len() * 3.6)
if telemeter.getDistance() < 5 and speed < 10 then
    if Nav.control.isAnyLandingGearExtended() == 0 then Nav.control.extendLandingGears() end
else
    if Nav.control.isAnyLandingGearExtended() == 1 then Nav.control.retractLandingGears() end
end

 

Link to comment
Share on other sites

2 minutes ago, GraXXoR said:

If you’re not worried about underwater landing gear, you don’t even need a telemeter.  This can be accomplished just by linking a hover engine to the core and using (iirc) the distance() method. 

Example pls. Will the distance be calculated to the object below or to the sea level?

Link to comment
Share on other sites

  • 1 month later...
On 9/18/2020 at 5:58 AM, _MOHAPX_ said:

Example pls. Will the distance be calculated to the object below or to the sea level?

When I follow these instructions, I get an error saying null value for Telemeter. I renamed the element. I am sure it has something to do with this but can't figure it out.

Link to comment
Share on other sites

  • 11 months later...
On 10/20/2020 at 6:51 AM, Doombad said:

When I follow these instructions, I get an error saying null value for Telemeter. I renamed the element. I am sure it has something to do with this but can't figure it out.

 

Yeah, a similar script works on another ship of mine - but on the new ship I am building I cannot even link the telemeter to the command seat ("no compatible link type ...").
So, I do not then see the telemeter "slot" - thus I cannot rename it.
Was there any change I am not aware of?
How am I supposed to link the telemeter now?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...