public Program() { MyProperty = new KProperty(this); MyProperty.Load(); Runtime.UpdateFrequency = UpdateFrequency.Update100; drawingSurface = Me.GetSurface(0); drawingSurface.ContentType = ContentType.TEXT_AND_IMAGE; Search(); }
private void Init() { MyProperty = new KProperty(this); MyProperty.Load(); Stage = 0; bottom_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Bottom Pistons"); bottom_pistons.ForEach(delegate(IMyPistonBase block) { block.MinLimit = MyProperty.locker_position_min; block.MaxLimit = MyProperty.locker_position_max; }); bottom_mergers = BlockSystem <IMyShipMergeBlock> .SearchByGroup(this, "Foreuse Bottom Mergers"); top_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Top Pistons"); top_pistons.ForEach(delegate(IMyPistonBase block) { block.MinLimit = MyProperty.locker_position_min; block.MaxLimit = MyProperty.locker_position_max; }); top_mergers = BlockSystem <IMyShipMergeBlock> .SearchByGroup(this, "Foreuse Top Mergers"); connector = BlockSystem <IMyShipConnector> .SearchByName(this, "Foreuse Connector Drills"); levage_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Levage Pistons"); levage_pistons.ForEach(delegate(IMyPistonBase block) { block.MinLimit = MyProperty.elevator_position_min; block.MaxLimit = MyProperty.elevator_position_max; }); grinder_stator = BlockSystem <IMyMotorStator> .SearchByName(this, "Foreuse Grinder Stator"); grinders = BlockSystem <IMyShipGrinder> .SearchByGroup(this, "Foreuse Grinders"); welder_stator = BlockSystem <IMyMotorStator> .SearchByName(this, "Foreuse Welder Stator"); welders = BlockSystem <IMyShipWelder> .SearchByGroup(this, "Foreuse Welders"); projector = BlockSystem <IMyProjector> .SearchByName(this, "Foreuse Projector Drill"); light = BlockSystem <IMyLightingBlock> .SearchByGroup(this, "Foreuse Rotating Light"); drills = BlockSystem <IMyShipDrill> .SearchByGroup(this, "Foreuse Drills"); control_lcds = BlockSystem <IMyTextPanel> .SearchByName(this, "Foreuse Control LCD"); control_lcds.ForEach(delegate(IMyTextPanel block) { block.ContentType = ContentType.TEXT_AND_IMAGE; }); SequenceBlocks = new List <int>() { }; }
public Program() { MyProperty = new KProperty(this); MyProperty.Load(); drawingSurface = Me.GetSurface(0); drawingSurface.ContentType = ContentType.TEXT_AND_IMAGE; // Set the continuous update frequency of this script Runtime.UpdateFrequency = UpdateFrequency.Update10; phase = Phase.None; Prepare(); }
private void RunCommand(string argument) { MyProperty.Load(); if (argument != null) { commandLine.TryParse(argument); var command = commandLine.Argument(0); switch (command) { default: machine_state = StateMachine.TrakingLat; last_power = 0f; break; } } }
public Program() { MyProperty = new KProperty(this); MyProperty.Load(); drawingSurface = Me.GetSurface(0); drawingSurface.ContentType = ContentType.TEXT_AND_IMAGE; Runtime.UpdateFrequency = UpdateFrequency.Update100; lat_stators = BlockSystem <IMyMotorStator> .SearchByName(this, MyProperty.Name); if (!lat_stators.IsEmpty) { lon_stators = BlockSystem <IMyMotorStator> .SearchByGrid(this, lat_stators.First.Top.CubeGrid); solar_panels = new BlockSystem <IMySolarPanel>(); foreach (IMyMotorStator lon_stator in lon_stators.List) { solar_panels.Merge(BlockSystem <IMySolarPanel> .SearchByGrid(this, lon_stator.Top.CubeGrid)); } } }
private void RunCommand(string argument) { MyProperty.Load(); if (argument != null) { commandLine.TryParse(argument); var command = commandLine.Argument(0); switch (command) { case "start": slowDown = false; stateMachine = StateMachine.Running; break; case "stop": stateMachine = StateMachine.Stopping; break; case "reset": Prepare(); stateMachine = StateMachine.Initializing; break; case "prepare": Prepare(); break; case "rotorZero": stateMachine = StateMachine.RotorZero; phase = Phase.None; break; default: Prepare(); break; } } }
private void RunCommand(string argument) { MyProperty.Load(); Init(); if (argument != null) { commandLine.TryParse(argument); var command = commandLine.Argument(0); if (command != null) { command = command.Trim().ToLower(); } switch (command) { case "default": Me.CustomData = ""; MyProperty.Load(); MyProperty.Save(); break; case "forceupdate": ForceUpdate = true; break; case "test": IMyTextPanel lcd = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(commandLine.Argument(1)); lcd.ScriptBackgroundColor = Color.Black; Drawing drawing = new Drawing(lcd); drawing.Test(); drawing.Dispose(); break; case "getname": int index = 0; int.TryParse(commandLine.Argument(1), out index); var names = new List <string>(); drawingSurface.GetSprites(names); Echo($"Sprite {index} name={names[index]}"); IMyTextPanel lcdResult = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("Result Name"); lcdResult.ContentType = ContentType.TEXT_AND_IMAGE; lcdResult.WriteText($"Sprite {index}\n", false); lcdResult.WriteText($"name={names[index]}", true); break; case "gettype": int.TryParse(commandLine.Argument(1), out index); string name = commandLine.Argument(1); IMyTerminalBlock block = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(name); IMyTextPanel lcdResult2 = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("Result Type"); lcdResult2.ContentType = ContentType.TEXT_AND_IMAGE; lcdResult2.WriteText($"Block {name}\n", false); lcdResult2.WriteText($"Type Name={block.GetType().Name}\n", true); lcdResult2.WriteText($"SubtypeName={block.BlockDefinition.SubtypeName}\n", true); lcdResult2.WriteText($"SubtypeId={block.BlockDefinition.SubtypeId}\n", true); break; default: search = true; Search(); break; } } }
private void Staging(ActionMachine action) { bool closed = true; float position_target = 0f; float velocity = 0f; switch (action) { case ActionMachine.LockBottom: velocity = -MyProperty.locker_velocity; position_target = MyProperty.locker_position_min; bottom_mergers.On(); bottom_pistons.Velocity(velocity); WriteText($"Bottom mergers: On", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; bottom_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (bottom_pistons.IsLessPosition(position_target)) { Stage++; } break; case ActionMachine.UnlockBottom: closed = true; top_mergers.ForEach(delegate(IMyShipMergeBlock block) { if (!block.IsConnected) { closed = false; } }); if (!closed) { WriteText($"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", true); WriteText($"Security: Top mergers is Off", true); } else { velocity = MyProperty.locker_velocity; position_target = MyProperty.locker_position_max; bottom_mergers.Off(); bottom_pistons.Velocity(velocity); WriteText($"Bottom mergers: Off", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; bottom_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (bottom_pistons.IsMorePosition(position_target)) { Stage++; } } break; case ActionMachine.LockTop: velocity = -MyProperty.locker_velocity; position_target = MyProperty.locker_position_min; top_mergers.On(); top_pistons.Velocity(velocity); WriteText($"Bottom mergers: On", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; top_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (top_pistons.IsLessPosition(position_target)) { connector.Lock(); Stage++; } break; case ActionMachine.UnlockTop: closed = true; bottom_mergers.ForEach(delegate(IMyShipMergeBlock block) { if (!block.IsConnected) { closed = false; } }); if (!closed) { WriteText($"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", true); WriteText($"Security: Bottom mergers is Off", true); } else { velocity = MyProperty.locker_velocity; position_target = MyProperty.locker_position_max; top_mergers.Off(); top_pistons.Velocity(velocity); connector.Unlock(); WriteText($"Top mergers: Off", true); WriteText($"Connector: Unlock", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; top_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (top_pistons.IsMorePosition(position_target)) { Stage++; } } break; case ActionMachine.Down: levage_pistons.On(); WriteText($"Piston Levage: On", true); velocity = MyProperty.elevator_velocity_min; if (Mode == ModeMachine.Up) { velocity = MyProperty.elevator_velocity_max; } WriteText($"Piston Velocity: {velocity}", true); levage_pistons.Velocity(velocity); position_target = MyProperty.elevator_position_max; WriteText($"Target Position={position_target}", true); levage_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); //projector_count = projector.List[0].RemainingBlocks; if (levage_pistons.IsMorePosition(position_target)) { Stage++; } break; case ActionMachine.Up: levage_pistons.On(); WriteText($"Piston Levage: On", true); velocity = -MyProperty.elevator_velocity_max; if (Mode == ModeMachine.Up) { velocity = -MyProperty.elevator_velocity_min; } WriteText($"Piston Velocity: {velocity}", true); levage_pistons.Velocity(velocity); position_target = MyProperty.elevator_position_min; WriteText($"Target Position={position_target}", true); levage_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); //projector_count = projector.List[0].RemainingBlocks; if (levage_pistons.IsLessPosition(position_target + 0.1f)) { Stage++; } break; case ActionMachine.StartWelder: projector.On(); welders.On(); WriteText($"Welders: On", true); Stage++; break; case ActionMachine.StopWelder: welders.Off(); projector.Off(); WriteText($"Welders: Off", true); Stage++; break; case ActionMachine.StartGrinder: grinders.On(); //projector.On(); WriteText($"Grinders: On", true); Stage++; break; case ActionMachine.StopGrinder: grinders.Off(); //projector.Off(); WriteText($"Grinders: Off", true); Stage++; break; case ActionMachine.Terminated: Cycle -= 1; if (Cycle == 0) { Mode = ModeMachine.Stop; } Stage = 0; break; case ActionMachine.Start: MyProperty.Load(); light.On(); drills.On(); Stage++; break; case ActionMachine.Stop: projector.Off(); light.Off(); drills.Off(); Stage++; break; } }
private void Init() { MyProperty = new KProperty(this); MyProperty.Load(); }