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