void Write(string text, IMyCockpit cockpit, bool apnd = false, int screenNumber = 0) { //For Control Seat Screens: // 0 - Center // 1 - Top Left // 2 - Top Right // 3 - Bottom Left // 4 - Top Left IMyTextSurface screen = ((IMyTextSurfaceProvider)cockpit).GetSurface(screenNumber); screen.WriteText(text); }
public static bool HasThrustersInEveryDirection(this IMyCubeGrid Grid, IMyCockpit _cockpit = null) { IMyCockpit Cockpit = _cockpit != null ? _cockpit : GetFirstCockpit(Grid); if (Cockpit == null) { return(false); } List <IMyThrust> Thrusters = Grid.GetWorkingBlocks <IMyThrust>(); if (Thrusters.Count < 6) { return(false); // There physically can't be a thruster in every direction } bool HasForwardThrust = false; bool HasBackwardThrust = false; bool HasUpThrust = false; bool HasDownThrust = false; bool HasLeftThrust = false; bool HasRightThrust = false; foreach (IMyThrust Thruster in Grid.GetWorkingBlocks <IMyThrust>()) { if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Forward) { HasForwardThrust = true; } else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Backward) { HasBackwardThrust = true; } else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Up) { HasUpThrust = true; } else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Down) { HasDownThrust = true; } else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Left) { HasLeftThrust = true; } else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Right) { HasRightThrust = true; } } return(HasForwardThrust && HasBackwardThrust && HasUpThrust && HasDownThrust && HasLeftThrust && HasRightThrust); }
public Program() { cockpit = GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit") as IMyCockpit; //roterR1 = GridTerminalSystem.GetBlockWithName("Arm R1") as IMyMotorStator; //roterR2 = GridTerminalSystem.GetBlockWithName("Arm R2") as IMyMotorStator; //roterL1 = GridTerminalSystem.GetBlockWithName("Arm L1") as IMyMotorStator; //roterL2 = GridTerminalSystem.GetBlockWithName("Arm L2") as IMyMotorStator; //text = GridTerminalSystem.GetBlockWithName("Text panel") as IMyTextPanel; targetAngle = Vector2.Zero; Runtime.UpdateFrequency = UpdateFrequency.Update1; elevationAngle = 0f; azimuthangle = 0f; }
private bool CollectBlocks(IMyTerminalBlock block) { if (Me.CubeGrid.EntityId != block.CubeGrid.EntityId) { return(false); } if (block is IMyCockpit && block.CustomName.Contains("[SPINMINER]")) { Cockpit = (IMyCockpit)block; Displays.Add(Cockpit.GetSurface(0)); } return(false); }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { this.objectBuilder = objectBuilder; try { cockpit = (IMyCockpit)Entity; updateHook = true; CoreHolo.UpdateHook += Update; //constrain its position } catch (Exception ex) { Log.DebugWrite(DebugLevel.Error, ex); } }
public Spaceship(IMyGridTerminalSystem system, IMyIntergridCommunicationSystem igc) { this.system = system; this.igc = igc; cpu = FindRunningPB(system); control = FindBlockOfType <IMyRemoteControl>(system, this, Settings.TAG); connector = FindBlockOfType <IMyShipConnector>(system, this, Settings.TAG); debug = FindBlockOfType <IMyTextPanel>(system, this, Settings.TAG); if (debug == null) { IMyCockpit cockpit = FindBlockOfType <IMyCockpit>(system, this, Settings.TAG); if (cockpit.SurfaceCount > 0) { debug = cockpit.GetSurface(0); } } debug.Font = "Monospace"; debug.ContentType = ContentType.TEXT_AND_IMAGE; /* * screen = cockpit.GetSurface(0); * screen.ContentType = ContentType.SCRIPT; * MySpriteDrawFrame frame = screen.DrawFrame(); * * * frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(0, 0), new Vector2(512, 512), Color.Black)); * frame.Add(MySprite.CreateText("Ftiaxe Me!!!", "DEBUG", Color.White)); * frame.Dispose(); */ listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener.SetMessageCallback(Settings.COMM_CHANNEL); thrusters = new ThrustersManager(this, control, system); autopilot = new Autopilot(this, control, FindBlockOfType <IMyGyro>(system, this)); cas = new CollisionAvoidanceSystem(this); fd = new FlightDirector(this); if (connector.Status == MyShipConnectorStatus.Connected) { flags = SpaceshipFlags.Dock; } else { flags = SpaceshipFlags.Idle; } }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; mainCockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName(MainCockpitName); foreach (string name in AirlockDoorNames) { string[] names = name.Split(';'); Airlock airlock = new Airlock(names[0], names[1], AirlockTimer); airlock.D1 = GridTerminalSystem.GetBlockWithName(names[0]) as IMyDoor; airlock.D2 = GridTerminalSystem.GetBlockWithName(names[1]) as IMyDoor; airlocks.Add(airlock); } }
public AdvanceControlShip(IMyRemoteControl remote) { m_shipControl = remote; m_cockpit = null; m_remote = remote; Matrix cockOrientation = new Matrix(); m_shipControl.Orientation.GetMatrix(out cockOrientation); rotation_Bcockpit_2_Bship = cockOrientation; rotation_Bship_2_Bcockpit = MatrixD.Transpose(rotation_Bcockpit_2_Bship); //Transpose is quicker than invert, and equivalent in this case lcd1 = null; }
public Program() { rotersR = new List <IMyTerminalBlock>(); rotersL = new List <IMyTerminalBlock>(); gunner = GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit No Oxygen") as IMyCockpit; cockpit = GridTerminalSystem.GetBlockWithName("Azimuth Passenger Seat") as IMyCockpit; roter1 = GridTerminalSystem.GetBlockWithName("Rotor Turret") as IMyMotorBase; roter2 = GridTerminalSystem.GetBlockWithName("Two-ended Motor") as IMyMotorBase; GridTerminalSystem.GetBlockGroupWithName("RotersR").GetBlocks(rotersR); GridTerminalSystem.GetBlockGroupWithName("RotersL").GetBlocks(rotersL); text = GridTerminalSystem.GetBlockWithName("Text panel") as IMyTextPanel; Runtime.UpdateFrequency = UpdateFrequency.Update1; }
void SetCockpitScreenText(IMyCockpit cockpit, int screenNumber, string text) { try { if (screenNumber + 1 <= cockpit.SurfaceCount) { IMyTextSurface lcdControl = cockpit.GetSurface(screenNumber); lcdControl.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE; lcdControl.WriteText(text); } } catch { } }
bool FuncTest(IMyCockpit block) { //Cockpit //Control Station //Flight Seat //Passenger Seat //Interface name: IMyCockpit //Parent: IMyShipController //Fields: bool ControlWheels = block.ControlWheels; bool ControlThrusters = block.ControlThrusters; bool HandBrake = block.HandBrake; bool DampenersOverride = block.DampenersOverride; return(true); }
public InventoriesController(CoordinatesTransformer tformer, IMyGridTerminalSystem gts, IMyCockpit cockpit, double idealCenterOfMass, IProcessSpawner spawner) { this._cpit = cockpit; this._idealCoM = idealCenterOfMass; var containers = new List <IMyCargoContainer>(); gts.GetBlocksOfType(containers, c => c.CubeGrid == cockpit.CubeGrid); this._invs = containers .Select(c => new Inventory(c, tformer.Pos(c.GetPosition()).Z)) .OrderBy(inv => inv.Z) .ToList(); gts.GetBlocksOfType(this._lights, light => light.DisplayNameText.StartsWith("BM Spotlight") && !light.DisplayNameText.Contains("Rear")); spawner.Spawn(p => this.updateDrills(), "drill-updater"); this._invAction = spawner.Spawn(p => this.updateInventories(tformer.Pos(cockpit.CenterOfMass).Z), "inv-handle", period: 100); }
public Program() { // The constructor, called only once every session and // always before any other method is called. Use it to // initialize your script. // // The constructor is optional and can be removed if not // needed. this.block = Me; surface = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("Panel"); sensor = (IMySensorBlock)GridTerminalSystem.GetBlockWithName("Sensor"); cockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit"); // set surface contentType // this is selecting type on terminal surface.ContentType = ContentType.SCRIPT; Runtime.UpdateFrequency = UpdateFrequency.Update1; }
void ParseCockpitConfigData(IMyCockpit cockpit) { if (!cockpit.CustomData.Contains(sectionTag)) { cockpit.CustomData += $"[{sectionTag}]\n{cockpitRangeFinderKey}={cockpitRangeFinderSurface}\n"; } MyIniParseResult result; myIni.TryParse(cockpit.CustomData, sectionTag, out result); if (!string.IsNullOrEmpty(myIni.Get(sectionTag, cockpitRangeFinderKey).ToString())) { cockpitRangeFinderSurface = myIni.Get(sectionTag, cockpitRangeFinderKey).ToInt32(); SURFACES.Add(cockpit.GetSurface(cockpitRangeFinderSurface)); } }
Program() { gts = GridTerminalSystem; cockpit = gts.GetBlockWithName(COCKPIT) as IMyCockpit; sound = gts.GetBlockGroupWithName(SOUND) as IMySoundBlock; radar = new Radar(RADAR); arta = new Artillery(ARTA, cockpit, 1200, 900); Torpedos = new List <Torpedo>(); InitializeTorpedos(); WolfPackDelays = new List <int>(); lcd = gts.GetBlockWithName(LCD) as IMyTextPanel; if (lcd == null) { lcd = cockpit.GetSurface(0) as IMyTextPanel; } }
void LoadConf() { if (Me.CustomData == prevCustomData) { return; } var conf = Me.CustomData.LoadDict(); cockpitName = conf.GetValue("Cockpit", null); cachedCockpit = null; rotorYawName = conf.GetValue("RotorYaw", null); rotorPitchName = conf.GetValue("RotorPitch", null); prevCustomData = Me.CustomData; pistonXName = conf.GetValue("PistonZ", null); pistonZName = conf.GetValue("PistonX", null); }
public Program() { //myBlockGroupRightArm = new List<IMyTerminalBlock>(); //myBlockGroupLeftArm = new List<IMyTerminalBlock>(); //myBlockGroupRightLegh = new List<IMyTerminalBlock>(); //myBlockGroupLeftLegh = new List<IMyTerminalBlock>(); Gyros = new List <IMyGyro>(); thrusters = new List <IMyThrust>(); myBlockGroupMain = new List <IMyTerminalBlock>(); cockpit = GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit No Oxygen 3") as IMyCockpit; myCamera = GridTerminalSystem.GetBlockWithName("Camera") as IMyCameraBlock; GridTerminalSystem.GetBlocksOfType(thrusters); GridTerminalSystem.GetBlockGroupWithName("Main Thrusters").GetBlocks(myBlockGroupMain); GridTerminalSystem.GetBlocksOfType(Gyros); text = GridTerminalSystem.GetBlockWithName("LCD Panel") as IMyTextPanel; Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public Program() { _buttonEnabled = new bool[2][]; _buttonEnabled[0] = new bool[9]; _buttonEnabled[1] = new bool[9]; _buttonText = new string[2][]; _buttonText[0] = new string[9]; _buttonText[1] = new string[9]; _buttonData = new PressedButton[2][]; _buttonData[0] = new PressedButton[9]; _buttonData[1] = new PressedButton[9]; _oreStatus = new MaterialStatus(); _ignotStatus = new MaterialStatus(); // Find LCD Displays if (!InitDisplays()) { Echo("ERROR ON STARTUP: LCD ERROR"); return; } // Get Blocks we care about _cockpit = GridTerminalSystem.GetBlockWithName("ACockpit") as IMyCockpit; _assembler = GridTerminalSystem.GetBlockWithName("Assembler") as IMyAssembler; _oreCargo = GridTerminalSystem.GetBlockWithName("Ore Cargo Bin") as IMyCargoContainer; _ignotCargo = GridTerminalSystem.GetBlockWithName("Ignot Cargo Bin") as IMyCargoContainer; _materialCargo = GridTerminalSystem.GetBlockWithName("Material Cargo Bin") as IMyCargoContainer; _bay1Connector = GridTerminalSystem.GetBlockWithName("Bay 1 Connector") as IMyShipConnector; _bay2Connector = GridTerminalSystem.GetBlockWithName("Bay 2 Connector") as IMyShipConnector; _bay3Connector = GridTerminalSystem.GetBlockWithName("Bay 3 Connector") as IMyShipConnector; _bay4Connector = GridTerminalSystem.GetBlockWithName("Bay 4 Connector") as IMyShipConnector; ////Runtime.UpdateFrequency = UpdateFrequency.Update100; init = true; Echo("Startup complete"); StartWizard(); }
public Program() { commands["cycle"] = Cycle; commands["enable"] = Enable; cockpit = GridTerminalSystem.GetBlockWithName("Fighter Cockpit") as IMyCockpit; camera = GridTerminalSystem.GetBlockWithName("Proximity Camera") as IMyCameraBlock; camera.EnableRaycast = true; proximityLCD = cockpit.GetSurface(2); altitudeLCD = cockpit.GetSurface(3); hinges = new List <IMyMotorStator>(); pistons = new List <IMyPistonBase>(); GridTerminalSystem.GetBlockGroupWithName("Landing Gear Hinges").GetBlocksOfType(hinges); GridTerminalSystem.GetBlockGroupWithName("Landing Gear Pistons").GetBlocksOfType(pistons); Runtime.UpdateFrequency = UpdateFrequency.Update10; }
public Program() { m_Cockpit = GridTerminalSystem.GetBlockWithName("Aquila Cockpit") as IMyCockpit; m_BatteryIntegrityDisplay = m_Cockpit.GetSurface(BatteryIntegrityDisplayIndex); GridTerminalSystem.GetBlocksOfType(m_Batteries, a => a is IMyBatteryBlock); var allBlocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(allBlocks); foreach (var block in allBlocks) { m_AllBlocks.Add(new KeyValuePair <IMyTerminalBlock, IMySlimBlock>(block, block.CubeGrid.GetCubeBlock(block.Position))); } m_Gyros = new List <IMyGyro>(); GridTerminalSystem.GetBlocksOfType(m_Gyros, a => a.IsSameConstructAs(m_Cockpit)); Runtime.UpdateFrequency = UpdateFrequency.Update10; }
public bool Drive(IMyCockpit cockpit) { bool returnvalue = false; nowTime = DateTime.UtcNow; // if (cockpit.RotationIndicator.X > 0) // { // myMotor1.MyMotor.TargetVelocityRad = cockpit.RotationIndicator.X/2; // } // else if (cockpit.RotationIndicator.X < 0) // { // myMotor1.MyMotor.TargetVelocityRad = cockpit.RotationIndicator.X/2; // } // else // { // myMotor1.MyMotor.TargetVelocityRad = 0; // } // if (cockpit.RotationIndicator.Y > 0) // { // myMotor2.MyMotor.TargetVelocityRad = -cockpit.RotationIndicator.Y/2; // } // else if (cockpit.RotationIndicator.Y < 0) // { // myMotor2.MyMotor.TargetVelocityRad = -cockpit.RotationIndicator.Y/2; // } // else // { // myMotor2.MyMotor.TargetVelocityRad = 0; // } foreach (var item in moters) { item.Update(); } befTime = nowTime; return(returnvalue); }
public Program() { string[] splitStorage; if (string.IsNullOrEmpty(Storage)) { splitStorage = new[] { "", "90", "90" }; } else { splitStorage = Storage.Split(';'); } var cockpitId = splitStorage[0]; _targetXAngle = float.Parse(splitStorage[1]); _targetYAngle = float.Parse(splitStorage[2]); IMyCockpit cockpit = null; if (!string.IsNullOrEmpty(cockpitId)) { long id; long.TryParse(cockpitId, out id); cockpit = GridTerminalSystem.GetBlockWithId(id) as IMyCockpit; if (!cockpit.IsMainCockpit) { cockpit = null; } } if (cockpit == null) { cockpit = GridTerminalSystem.GetMainCockpit(); } _mainCockpit = cockpit; _hinges = GridTerminalSystem.GetBlockGroupWithName("ArmHinges").GetBlocksOfType <IMyMotorStator>(); _rotors = GridTerminalSystem.GetBlockGroupWithName("ArmRotors").GetBlocksOfType <IMyMotorStator>(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; var cockpits = new List <IMyCockpit>(); this.GridTerminalSystem.GetBlocksOfType(cockpits, c => c.CubeGrid == this.Me.CubeGrid); IMyCockpit cockpit = cockpits.First(); this.manager = Process.CreateManager(this.Echo); var ct = new CoordinatesTransformer(cockpit, this.manager); var logger = new Logger(this.manager, cockpit.GetSurface(0), new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f); this.cmd = new CommandLine("Small welder", logger.Log, this.manager); var ini = new IniWatcher(this.Me, this.manager); var wc = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct); var ac = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager); var client = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log); var ah = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc); ah.AddBraker(client); }
public Program() { gyros = new List <IMyTerminalBlock>(); cockpit = GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit") as IMyCockpit; GridTerminalSystem.GetBlockGroupWithName("Gyros").GetBlocks(gyros); text = GridTerminalSystem.GetBlockWithName("Text panel") as IMyTextPanel; myMotorR1 = GridTerminalSystem.GetBlockWithName("Hinge R1") as IMyMotorStator; myMotorR2 = GridTerminalSystem.GetBlockWithName("Hinge R2") as IMyMotorStator; myMotorR3 = GridTerminalSystem.GetBlockWithName("Hinge R3") as IMyMotorStator; myMotorL1 = GridTerminalSystem.GetBlockWithName("Hinge L1") as IMyMotorStator; myMotorL2 = GridTerminalSystem.GetBlockWithName("Hinge L2") as IMyMotorStator; myMotorL3 = GridTerminalSystem.GetBlockWithName("Hinge L3") as IMyMotorStator; Runtime.UpdateFrequency = UpdateFrequency.Update1; R1Flg = 0; L1Flg = 1; MovingFlg = 0; }
IMyShipController GetActiveController() { IMyShipController sc = null; bool bHasMain = false; for (int i = 0; i < controllersList.Count; i++) { IMyCockpit imyc = controllersList[i] as IMyCockpit; if (imyc != null) { if (imyc.IsMainCockpit) { bHasMain = true; if (imyc.IsUnderControl) { return(imyc); } else { Echo("Main cockpit not occupied:" + imyc.CustomName); } } } } if (bHasMain) { return(sc); // there IS a main and it's not occupied. } for (int i = 0; i < controllersList.Count; i++) { if (((IMyShipController)controllersList[i]).IsUnderControl) { sc = controllersList[i] as IMyShipController; break; } } return(sc); }
public void Main(string argument, UpdateType updateSource) { double levelElevation = 10000.00; double slowElevation = 8000; double stopVelocity = 1000; IMyRemoteControl remoteControl = GridTerminalSystem.GetBlockWithName("Remote Control") as IMyRemoteControl; IMyGyro gyroscope = GridTerminalSystem.GetBlockWithName("Gyroscope") as IMyGyro; IMyCockpit cockpit = GridTerminalSystem.GetBlockWithName("Control Seat") as IMyCockpit; IMyProgrammableBlock autoLevel = (IMyProgrammableBlock)GridTerminalSystem.GetBlockWithName("Prog Block Auto Level"); Echo(remoteControl.CustomName); Echo(gyroscope.CustomName); StringBuilder sb = new StringBuilder(); double basicVel = remoteControl.GetShipSpeed(); double elevation; remoteControl.TryGetPlanetElevation(MyPlanetElevation.Surface, out elevation); sb.AppendLine($"Vel: {basicVel}\n Elev: {elevation.ToString("0.00")}"); if (stopVelocity <= elevation) { sb.AppendLine($"Level Limit Reached"); } else if (slowElevation <= elevation) { sb.AppendLine($"Level Limit Reached"); } else if (levelElevation <= elevation) { sb.AppendLine($"Level Limit Reached"); } Write(sb.ToString(), cockpit); }
public static void KeepHorizon(string arg, ref bool keepHorizon, IMyCockpit cockpit, List <IMyGyro> gyros) { switch (arg) { case KeepHorizonOffArg: keepHorizon = false; break; case KeepHorizonOnArg: keepHorizon = true; break; } foreach (var gyro in gyros) { gyro.GyroOverride = keepHorizon; } if (keepHorizon) { Vector3D grav = Vector3D.Normalize(cockpit.GetNaturalGravity()); Vector3D axis = grav.Cross(cockpit.WorldMatrix.Down); var signal = cockpit.WorldMatrix.Up * cockpit.RollIndicator; if (grav.Dot(cockpit.WorldMatrix.Down) < 0) { axis = Vector3D.Normalize(axis); } axis += signal; foreach (var gyro in gyros) { gyro.Yaw = (float)axis.Dot(gyro.WorldMatrix.Up); gyro.Pitch = (float)axis.Dot(gyro.WorldMatrix.Right); gyro.Roll = (float)axis.Dot(gyro.WorldMatrix.Backward); } } }
/// <summary> /// コンストラクタ /// </summary> public Program() { cockpit = GridTerminalSystem.GetBlockWithName("Azimuth Open Cockpit") as IMyCockpit; GridTerminalSystem.GetBlockGroupWithName("Gyros").GetBlocks(gyros); roterR1 = GridTerminalSystem.GetBlockWithName("Hinge R1") as IMyMotorStator; roterR2 = GridTerminalSystem.GetBlockWithName("Hinge R2") as IMyMotorStator; roterR3 = GridTerminalSystem.GetBlockWithName("Hinge R3") as IMyMotorStator; roterL1 = GridTerminalSystem.GetBlockWithName("Hinge L1") as IMyMotorStator; roterL2 = GridTerminalSystem.GetBlockWithName("Hinge L2") as IMyMotorStator; roterL3 = GridTerminalSystem.GetBlockWithName("Hinge L3") as IMyMotorStator; ArmR1 = GridTerminalSystem.GetBlockWithName("Rotor R") as IMyMotorStator; ArmR2 = GridTerminalSystem.GetBlockWithName("Small Conveyor Hinge R1") as IMyMotorStator; ArmL1 = GridTerminalSystem.GetBlockWithName("Rotor L") as IMyMotorStator; ArmL2 = GridTerminalSystem.GetBlockWithName("Small Conveyor Hinge L1") as IMyMotorStator; mySensor = GridTerminalSystem.GetBlockWithName("Sensor") as IMySensorBlock; text = GridTerminalSystem.GetBlockWithName("Text panel") as IMyTextPanel; befTime = DateTime.UtcNow; buff1 = new LegBase(roterR1, true, roterR2, false, roterR3, true); buff2 = new LegBase(roterL1, false, roterL2, false, roterL3, true); Arm1 = new ArmBase(ArmR1, true, ArmR2, false, ArmR2, false); Arm2 = new ArmBase(ArmL1, false, ArmL2, false, ArmL2, false); DriveEntity = new HaltClass(buff1, buff2, Arm1, Arm2); st = "Walk"; Me.CustomData = "Walk"; Runtime.UpdateFrequency = UpdateFrequency.Update1; nowTime = DateTime.UtcNow; befTime = DateTime.UtcNow; }
// This file contains your actual script. // // You can either keep all your code here, or you can create separate // code files to make your program easier to navigate while coding. // // In order to add a new utility class, right-click on your project, // select 'New' then 'Add Item...'. Now find the 'Space Engineers' // category under 'Visual C# Items' on the left hand side, and select // 'Utility Class' in the main area. Name it in the box below, and // press OK. This utility class will be merged in with your code when // deploying your final script. // // You can also simply create a new utility class manually, you don't // have to use the template if you don't want to. Just do so the first // time to see what a utility class looks like. public void Main(string argument, UpdateType updateSource) { Runtime.UpdateFrequency = UpdateFrequency.Update1; IMyCockpit myCockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("Cockpit"); List <IMyThrust> forwardthrusters = new List <IMyThrust>(); List <IMyThrust> breakthrusters = new List <IMyThrust>(); forwardthrusters = GetMyForwardThrusts("ThrustForward"); breakthrusters = GetMyBreakThrusts("ThrustBackward"); double speed = myCockpit.GetShipSpeed(); Echo($"ship speed = {speed.ToString()}"); if (speed < 2 && 4 > speed) { foreach (IMyThrust forwardThrust in forwardthrusters) { forwardThrust.Enabled = true; forwardThrust.ThrustOverridePercentage = 1; } } else if (speed > 20 && speed < 30) { foreach (IMyThrust forwardThrust in forwardthrusters) { forwardThrust.Enabled = false; forwardThrust.ThrustOverridePercentage = 1; } } }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; rotorBase = GetBlock <IMyMotorStator>("RotorBase"); hingeBase = GetBlock <IMyMotorStator>("HingeBase"); rotorMiddle = GetBlock <IMyMotorStator>("RotorMiddle"); hingeEnd = GetBlock <IMyMotorStator>("HingeEnd"); IMyCockpit cockpit = GetBlock <IMyCockpit>("Controller"); controller = cockpit; controllerPanel = cockpit.GetSurface(0); debugPanel = GetBlock <IMyTextSurface>("DebugPanel"); targetPosition = hingeEnd.GetPosition() - hingeBase.GetPosition(); if (Math.Abs(Vector3D.Distance(hingeBase.GetPosition(), rotorMiddle.GetPosition()) - Vector3D.Distance(rotorMiddle.GetPosition(), hingeEnd.GetPosition())) > 0.1) { throw new Exception("Arms have different lengths."); } armLength = Vector3D.Distance(hingeBase.GetPosition(), rotorMiddle.GetPosition()); hingeBaseSign = -Math.Sign(Vector3D.Dot(targetPosition, hingeBase.WorldMatrix.Forward)); rotorMiddleSign = -Math.Sign(Vector3D.Dot(hingeBase.WorldMatrix.Right, rotorMiddle.WorldMatrix.Up)) * hingeBaseSign; Vector3D rotorMiddleToBase = hingeBase.GetPosition() - rotorMiddle.GetPosition(); rotorMiddleOffset = AngleTowards(rotorMiddle, hingeEnd, Vector3D.Normalize(rotorMiddleToBase)); pidRotor.Init(1, 0.5, 0.01); pidBase.Init(1, 0.5, 0.01); pidMid.Init(1, 0.5, 0.01); locked = true; }