public LuaValue proxyLandAt(LuaValue[] args) { if (args.Count() < 2 && args.Count() > 3) { throw new Exception("landAt usage: landAt(latitude, longitude) or landAt(latitude, longitude, autoWarpOnDescent)"); } double argLatitude; double argLongitude; try { argLatitude = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("landAt: invalid latitude"); } try { argLongitude = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("landAt: invalid longitude"); } if (args.Count() == 3) { try { autoWarpOnDescent = ((LuaBoolean)args[2]).BoolValue; } catch (Exception) { throw new Exception("landAt: invalid autoWarpOnDescent"); } } else { autoWarpOnDescent = true; } landAt(argLatitude, argLongitude); return LuaNil.Nil; }
public LuaValue proxyWarpToEvent(LuaValue[] args) { if (args.Count() == 0 || args.Count() > 2) throw new Exception("warpToEvent usage: warpToEvent(event) or warpToEvent(event, lead time)"); try { if (args[0].ToString().ToLower().Contains("pe")) warpPoint = WarpPoint.PERIAPSIS; else if (args[0].ToString().ToLower().Contains("ap")) warpPoint = WarpPoint.APOAPSIS; else if (args[0].ToString().ToLower().Contains("soi")) warpPoint = WarpPoint.SOI_CHANGE; else throw new Exception("warpToEvent: event must be one of \"pe\", \"ap\", \"soi\""); } catch (Exception) { throw new Exception("warpToEvent: invalid event"); } if (args.Count() == 2) { try { warpTimeOffset = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("warpToEvent: invalid lead time"); } } else { warpTimeOffset = 0; } warpTimeOffsetString = warpTimeOffset.ToString(); this.enabled = true; core.controlClaim(this); currentOperation = Operation.WARP; guiTab = Operation.WARP; return LuaNil.Nil; }
public LuaValue proxyHold(LuaValue[] args) { if (args.Count() != 2) throw new Exception("ilsHold usage: ilsHold(altitude [in meters], heading [in degrees])"); double altitude; double heading; try { altitude = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("ilsHold: invalid altitude"); } try { heading = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("ilsHold: invalid heading"); } hold(altitude, heading); return LuaNil.Nil; }
public LuaValue proxyChangePe(LuaValue[] args) { if (args.Count() != 1) throw new Exception("changePe usage: changePe(periapsis [in meters])"); try { newPeA = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("changePe: invalid periapsis"); } newPeAString = (newPeA / 1000.0).ToString(); this.enabled = true; core.controlClaim(this); currentOperation = Operation.PERIAPSIS; raisingApsis = (part.vessel.orbit.PeA < newPeA); guiTab = Operation.PERIAPSIS; return LuaNil.Nil; }
public LuaValue proxyTransfer(LuaValue[] args) { if (args.Count() != 2) throw new Exception("transfer usage: transfer(target body, final periapsis [in meters])"); try { foreach (CelestialBody body in part.vessel.mainBody.orbitingBodies) { if (body.name.ToLower().Contains(args[0].ToString().ToLower())) { transferTarget = body; break; } } } catch (Exception) { throw new Exception("transfer: invalid target body"); } try { desiredPostTransferPeA = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("transfer: invalid final periapsis"); } desiredPostTransferPeAString = (desiredPostTransferPeA / 1000.0).ToString(); this.enabled = true; core.controlClaim(this); currentOperation = Operation.TRANSFER_INJECTION; transState = TRANSState.WAITING_FOR_INJECTION; guiTab = Operation.TRANSFER_INJECTION; return LuaNil.Nil; }
public LuaValue proxyAttitudeTo(LuaValue[] arg) { if ((arg.Count() != 2) || !(arg[0] is LuaTable)) { throw new Exception("usage: attitudeTo(vector, reference)"); } AttitudeReference r; try { r = (AttitudeReference)Enum.Parse(typeof(AttitudeReference), arg[1].ToString(), true); } catch (Exception) { throw new Exception("attitudeTo: invalid reference"); } if (((LuaTable)arg[0]).Count == 4) { Quaternion dir; try { dir = LuaUtils.valueToQuaternion(arg[0]); } catch (Exception e) { throw new Exception("attitudeTo: invalid quaternion - " + e.Message); } return LuaBoolean.From(attitudeTo(dir, r, autom8)); } else { Vector3d dir; try { dir = LuaUtils.valueToVector3d(arg[0]); } catch (Exception e) { throw new Exception("attitudeTo: invalid vector - " + e.Message); } return LuaBoolean.From(attitudeTo(dir, r, autom8)); } }
public LuaValue proxyChangeApAndPe(LuaValue[] args) { if (args.Count() != 2) throw new Exception("changeAp usage: changeApAndPe(apoapsis[in meters], periapsis [in meters])"); try { newApA = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("changeAp: invalid apoapsis"); } try { newPeA = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("changeApAndPe: invalid periapsis"); } newApAString = (newApA / 1000.0).ToString(); newPeAString = (newPeA / 1000.0).ToString(); this.enabled = true; core.controlClaim(this); currentOperation = Operation.ELLIPTICIZE; guiTab = Operation.ELLIPTICIZE; return LuaNil.Nil; }
public LuaValue proxyThrustActivate(LuaValue[] arg) { TMode t = TMode.DIRECT; if ((arg.Count() > 1) && (arg[1] is LuaString)) { try { t = (TMode)Enum.Parse(typeof(TMode), arg[1].ToString(), true); } catch (Exception) { throw new Exception("thrustActivate: invalid mode"); } } return LuaBoolean.From(thrustActivate(autom8, ((arg.Count() > 0) && (arg[0] is LuaNumber)) ? (float)(arg[0] as LuaNumber).Number : 0, t)); }
public LuaValue proxyWarpIncrease(LuaValue[] arg) { return LuaBoolean.From(warpIncrease(autom8, (arg.Count() > 0) ? arg[0].GetBooleanValue() : true, ((arg.Count() > 1) && (arg[1] is LuaNumber)) ? (arg[1] as LuaNumber).Number : 10000)); }
public LuaValue proxyGetModule(LuaValue[] arg) { return ObjectToLua.ToLuaValue(getModule((arg.Count() > 0) ? arg[0].ToString() : "")); }
//public LuaValue proxySetTarget(LuaValue[] arg) { } public LuaValue proxyLandActivate(LuaValue[] arg) { return LuaBoolean.From(landActivate(autom8, ((arg.Count() > 0) && (arg[0] is LuaNumber)) ? (arg[0] as LuaNumber).Number : 0.5)); }
public LuaValue proxyControlRelease(LuaValue[] arg) { return LuaBoolean.From(controlRelease(autom8, (arg.Count() > 0) ? arg[0].GetBooleanValue() : false)); }
public LuaValue proxyAutoStageActivate(LuaValue[] arg) { return LuaBoolean.From(autoStageActivate(autom8, ((arg.Count() > 0) && (arg[0] is LuaNumber)) ? (arg[0] as LuaNumber).Number : 1.0, ((arg.Count() > 1) && (arg[1] is LuaNumber)) ? (int)(arg[1] as LuaNumber).Number : 0)); }
public LuaValue proxyAttitudeWorldToReference(LuaValue[] arg) { if (arg.Count() != 2) { throw new Exception("usage: attitudeWorldToReference(vector, reference)"); } Vector3d dir; try { dir = LuaUtils.valueToVector3d(arg[0]); } catch (Exception e) { throw new Exception("attitudeWorldToReference: invalid vector - " + e.Message); } AttitudeReference r; try { r = (AttitudeReference)Enum.Parse(typeof(AttitudeReference), arg[1].ToString(), true); } catch (Exception) { throw new Exception("attitudeWorldToReference: invalid reference"); } return LuaUtils.Vector3dToTable(attitudeWorldToReference(dir, r)); }
public LuaValue proxySetLanding(LuaValue[] args) { if (args.Count() < 2) { throw new Exception("setLanding usage: setLanding(latitude, longitude)"); } double argLatitude; double argLongitude; try { argLatitude = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("landAt: invalid latitude"); } try { argLongitude = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("landAt: invalid longitude"); } setLanding(argLatitude, argLongitude); return LuaNil.Nil; }
public LuaValue proxyWarpPhysics(LuaValue[] arg) { warpPhysics(autom8, (arg.Count() > 0) ? arg[0].GetBooleanValue() : true); return LuaNil.Nil; }
public LuaValue proxyLaunchTo(LuaValue[] args) { if (args.Count() != 2) throw new Exception("launchTo usage: launchTo(altitude [in meters], inclination [in degrees])"); double orbitAltitude; double orbitInclination; try { orbitAltitude = ((LuaNumber)args[0]).Number; } catch (Exception) { throw new Exception("launchTo: invalid orbit altitude"); } try { orbitInclination = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("launchTo: invalid orbit inclination"); } launchTo(orbitAltitude, orbitInclination); return LuaNil.Nil; }
public LuaValue proxyAttitudeGetReferenceRotation(LuaValue[] arg) { if (arg.Count() != 1) { throw new Exception("usage: attitudeGetReferenceRotation(reference)"); } AttitudeReference r; try { r = (AttitudeReference)Enum.Parse(typeof(AttitudeReference), arg[0].ToString(), true); } catch (Exception) { throw new Exception("attitudeGetReferenceRotation: invalid reference"); } return LuaUtils.QuaternionToTable(attitudeGetReferenceRotation(r)); }