public static void Log(string logMessage, Action<string> echo = null, IMyProgrammableBlock me = null, string label = null, IMyTextPanel mirrorLcd = null, bool truncateForLcd = true) { String output = ""; if(echo == null) { output = "\n"; output += logMessage; throw new Exception(output); } if(LogBuffer == null) { LogBuffer = new StringBuilder(); } if(label != null) { logMessage = label+": "+logMessage; } if(mirrorLcd != null) { string currentlyMirrored = mirrorLcd.GetPublicText(); if(truncateForLcd && LogBuffer.Length + logMessage.Length > LOG_MAX_LCD_LENGTH_CHARS) { StringBuilder lcdBuffer = new StringBuilder(LogBuffer.ToString()); int charAmountToOffset = fullLineCharsExceeding(lcdBuffer, logMessage.Length, LogBuffer.Length - (LOG_MAX_LCD_LENGTH_CHARS - logMessage.Length)); lcdBuffer.Remove(0, LogBuffer.Length - LOG_MAX_LCD_LENGTH_CHARS + charAmountToOffset - 2); lcdBuffer.AppendLine(); lcdBuffer.Append(logMessage); mirrorLcd.WritePublicText(lcdBuffer.ToString(), false); } else { string potentialNewLine = (currentlyMirrored.Length > 0)? "\n" : ""; mirrorLcd.WritePublicText(potentialNewLine+logMessage, true); } } if(LogBuffer.Length + logMessage.Length * 2 > LOG_MAX_ECHO_LENGTH_CHARS) { int charAmountToRemove = fullLineCharsExceeding(LogBuffer, logMessage.Length); LogBuffer.Remove(0, charAmountToRemove); LogBuffer.Append(output); } if(LogBuffer.Length > 0) { LogBuffer.AppendLine(); } LogBuffer.Append(logMessage); echo(LogBuffer.ToString()); }
public EasyLCD(EasyBlocks block, double scale = 1.0) { this.block = block.GetBlock(0); if(this.block.Type() == "Wide LCD panel") this.wPanel = 72; this.screen = (IMyTextPanel)(block.GetBlock(0).Block); this.fontSize = block.GetProperty<Single>("FontSize"); this.width = (int)((double)this.wPanel / this.fontSize); this.height = (int)((double)this.hPanel / this.fontSize); this.buffer = new char[this.width * this.height]; this.clear(); this.update(); }
//IMyCockpit cockpit; public Program() { control = GridTerminalSystem.GetBlockWithName("Remote Control") as IMyRemoteControl; display = GridTerminalSystem.GetBlockWithName("LCD Test") as IMyTextPanel; //cockpit = GridTerminalSystem.GetBlockWithName("Flight Seat") as IMyCockpit; }
private TextPanelWriter(IMyTextPanel panel) { _panel = panel; _isWide = _panel.DefinitionDisplayNameText.Contains("Wide") || _panel.DefinitionDisplayNameText == "Computer Monitor"; _publicString = new StringBuilder(); _privateString = new StringBuilder(); Clear(); }
private TextPanelWriter(IMyTextPanel panel) { _panel = panel; _isWide = _panel.BlockDefinition.SubtypeName.IndexOf("Wide", StringComparison.InvariantCultureIgnoreCase) >= 0 || _panel.BlockDefinition.SubtypeName == "SmallMonitor" || _panel.BlockDefinition.SubtypeName == "LargeMonitor"; // Support for Mod 403922024. _publicString = new StringBuilder(); _privateString = new StringBuilder(); Clear(); }
private void GetBlocks() { string blockGroupName = configReader.Get <string>("blockGroupName"); IMyBlockGroup blockGroup = GridTerminalSystem.GetBlockGroupWithName(blockGroupName); List <IMyShipController> controllers = new List <IMyShipController>(); blockGroup.GetBlocksOfType <IMyShipController>(controllers); if (controllers.Count == 0) { throw new Exception("Error: " + blockGroupName + " does not contain a cockpit or remote control block."); } cockpit = controllers[0]; List <IMyTextPanel> textPanels = new List <IMyTextPanel>(); blockGroup.GetBlocksOfType <IMyTextPanel>(textPanels); if (textPanels.Count > 0) { textPanel = textPanels[0]; textPanel.Font = "Monospace"; textPanel.FontSize = 1.0f; textPanel.ShowPublicTextOnScreen(); } blockGroup.GetBlocksOfType <IMyGyro>(gyros); if (gyros.Count == 0) { throw new Exception("Error: " + blockGroupName + " does not contain any gyroscopes."); } }
public void Main(string argument, UpdateType updateSource) { IMyTextPanel LCDWritingScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(lcdName); // If setupcomplete is false, run Setup method. if (!setupcomplete) { Echo("Running setup."); Setup(); } else { // Create our message. We first make it a string, and then we "box" it as an object type. string messageOut = LCDWritingScreen.GetText(); // Through the IGC variable we issue the broadcast method. IGC is "pre-made", // so we don't have to declare it ourselves, just go ahead and use it. IGC.SendBroadcastMessage(broadcastChannel, messageOut, TransmissionDistance.TransmissionDistanceMax); // To create a listener, we use IGC to access the relevant method. // We pass the same tag argument we used for our message. IGC.RegisterBroadcastListener(broadcastChannel); } }
// Script constructor public Program() { // Me is the programmable block which is running this script. // Retrieve the Large Display, which is the first surface _drawingSurface = Me.GetSurface(0); StringBuilder sprts = new StringBuilder(); List <String> sprites = new List <String>(); _drawingSurface.GetSprites(sprites); sprites.ForEach(sprt => { sprts.Append($"{sprt}\n"); }); Me.CustomData = ""; Me.CustomData = sprts.ToString(); // Set the continuous update frequency of this script //Runtime.UpdateFrequency = UpdateFrequency.Update100; IMyTextPanel lcd = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("Shitty Fucky Test LCD"); _drawingSurface = lcd; // Calculate the viewport by centering the surface size onto the texture size _viewport = new RectangleF( (_drawingSurface.TextureSize - _drawingSurface.SurfaceSize) / 2f, _drawingSurface.SurfaceSize ); // Make the text surface display sprites PrepareTextSurfaceForSprites(_drawingSurface); }
//------------------------------------------------------------------------ // GetBlock //------------------------------------------------------------------------ private bool GetBlock <T> (String key, out T block, IMyTextPanel textPanel = null) where T : class { bool bFoundBlock = false; block = GridTerminalSystem.GetBlockWithName(key) as T; if (block != null) { bFoundBlock = true; } else { String message = "Cant find block with name <" + key + ">"; Echo(message); if (textPanel == null) { DrawText(message); } else { DrawText(textPanel, message); } } return(bFoundBlock); }
private bool GetBlock <T> (List <T> listBlock, IMyTextPanel textPanel = null) where T : class { bool bFoundBlock = false; GridTerminalSystem.GetBlocksOfType <T> (listBlock); if (listBlock.Count > 0) { bFoundBlock = true; } else { String message = "Cant find blocks of type <" + typeof(T) + ">"; Echo(message); if (textPanel == null) { DrawText(message); } else { DrawText(textPanel, message); } } return(bFoundBlock); }
//PUBLIC INTERFACE public CommandBus(IMyTextPanel bus) { this.bus = bus; store = null; readPos = 0; }
private void debug(string line, int logLevel = LOG_LVL_DEBUG) { if (usedLogLevel != LOG_LVL_SILENT) { if (usedLogLevel >= logLevel) { string prefix = ""; if (usedLogLevel >= LOG_LVL_DEBUG) { prefix = "[Tick#" + this.ElapsedTime.Ticks.ToString() + "]"; } line = prefix + line; Echo(line.Trim()); List <IMyTerminalBlock> LCDs = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(LCDs, (x => x.CustomName.Contains(TAG_LOG_DEBUG_LCD) && x.CubeGrid.Equals(Me.CubeGrid))); for (int i = 0; i < LCDs.Count; i++) { IMyTextPanel LCD = LCDs[i] as IMyTextPanel; StringBuilder sb = new StringBuilder(); sb.AppendLine(line); sb.Append(LCD.GetPublicText()); LCD.WritePublicText(sb.ToString()); } } } }
private void initBlock(string name) { Echo("initBlock() " + name); var block = GridTerminalSystem.GetBlockWithName(name); if (block != null) { if (block is IMyTextPanel) { lcd = block as IMyTextPanel; } } else { var group = GridTerminalSystem.GetBlockGroupWithName(name); if (group != null) { if (group is IMyBlockGroup) { batteryList.Clear(); (group as IMyBlockGroup).GetBlocksOfType <IMyBatteryBlock>(batteryList); } } } }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; _solar1 = GridTerminalSystem.GetBlockWithName("s1") as IMyPowerProducer; _solar2 = GridTerminalSystem.GetBlockWithName("s2") as IMyPowerProducer; _solar3 = GridTerminalSystem.GetBlockWithName("s3") as IMyPowerProducer; _solar4 = GridTerminalSystem.GetBlockWithName("s4") as IMyPowerProducer; _display1 = GridTerminalSystem.GetBlockWithName("display1") as IMyTextPanel; _display2 = GridTerminalSystem.GetBlockWithName("display2") as IMyTextPanel; _displayPower = GridTerminalSystem.GetBlockWithName("display-power") as IMyTextPanel; batteryInfo = new Dictionary <string, FixedSizedQueue <double> >(); batteryInfo["currentPower"] = new FixedSizedQueue <double>(5); batteryInfo["maxPower"] = new FixedSizedQueue <double>(1); batteryInfo["currentInput"] = new FixedSizedQueue <double>(20); batteryInfo["currentOutput"] = new FixedSizedQueue <double>(50); batteryInfo["currentNet"] = new FixedSizedQueue <double>(50); inventoryStats = new Dictionary <string, string>(); inventoryDisplayMapping = new Dictionary <string, IMyTextPanel>(); inventoryDisplayMapping["MyObjectBuilder_Ore"] = GridTerminalSystem.GetBlockWithName("display_ore") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Ingot"] = GridTerminalSystem.GetBlockWithName("display_ingot") as IMyTextPanel; inventoryDisplayMapping["MyObjectBuilder_Component"] = GridTerminalSystem.GetBlockWithName("display_comp") as IMyTextPanel; tempItemList = new List <MyInventoryItem>(); buildingItemTypes = new[] { "Ore", "Ingot", "Component" }; _logText = new FixedSizedQueue <string>(15); }
void _FindConfigScreen() { List <IMyTerminalBlock> _configScreens = new List <IMyTerminalBlock>(); // make sure that we only gather TextPanels GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(_configScreens); int _screens = 0; Debug("Screens found:" + _configScreens.Count); for (int i = 0; i < _configScreens.Count; i++) { if (_configScreens[i].CustomName.Contains(configID)) { _screens++; // there should`nt be more than 1! config = (IMyTextPanel)_configScreens[i]; Debug("ConfigScreen found who contains the name:" + configID); Debug("External config file found! Loading DATA..."); LoadExternalConfigData(); } if (_screens == 0) { Debug("No Configscreen found"); } } }
public SpanCanvas(IMyTextPanel corner) : base() { if (corner == null) { throw new Exception("Corner panel not found."); } Vector3I xAxis, yAxis; GetAxis(corner, out xAxis, out yAxis); Vector3I start = GetCorner(corner, xAxis, yAxis); // Determine the size of the panel area Vector3I v = start; Vector2I size = new Vector2I(); while (GetPanel(corner, v) != null) { v += xAxis; size.X++; } v = start; while (GetPanel(corner, v) != null) { v += yAxis; size.Y++; } globalSize = new Vector2(size.X, size.Y) * pixelDensity; LoadPanels(corner, start, xAxis, yAxis, size.X, size.Y); }
public void Main(string argument) { if (firstrun) { firstrun = false; List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocks(blocks); foreach (var block in blocks) { if (block is IMyCameraBlock) { camera = (IMyCameraBlock)block; } if (block is IMyTextPanel) { lcd = (IMyTextPanel)block; } } camera.EnableRaycast = true; } if (camera.CanScan(SCAN_DISTANCE)) { info = camera.Raycast(SCAN_DISTANCE, PITCH, YAW); } sb.Clear(); Echo("EntityID: " + info.EntityId); Echo("Name: " + info.Name); Echo("Type: " + info.Type); Echo("Velocity: " + info.Velocity.ToString("0.000")); Echo("Relationship: " + info.Relationship); Echo("Size: " + info.BoundingBox.Size.ToString("0.000")); Echo("Position: " + info.Position.ToString("0.000")); if (info.HitPosition.HasValue) { Echo("Hit: " + info.HitPosition.Value.ToString("0.000")); Echo("Distance: " + Vector3D.Distance(camera.GetPosition(), info.HitPosition.Value).ToString("0.00")); } Echo("Range: " + camera.AvailableScanRange.ToString()); /* * lcd.WritePublicText(sb.ToString()); * lcd.ShowPrivateTextOnScreen(); * lcd.ShowPublicTextOnScreen(); */ }
public Program() { base_prgblk = GridTerminalSystem.GetBlockWithName(base_prgblk_name) as IMyProgrammableBlock; drill_drills = GridTerminalSystem.GetBlockGroupWithName(drill_drills_name); drill_rotor = GridTerminalSystem.GetBlockGroupWithName(drill_rotor_name); drill_landing_gears_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_pistons_name); drill_landing_gears = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_name); drill_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name); text_panel_status = GridTerminalSystem.GetBlockWithName(text_panel_status_name) as IMyTextPanel; drill_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name); drill_connector = GridTerminalSystem.GetBlockWithName(drill_connector_name) as IMyShipConnector; //read stored config if (Storage.Length != 0) { string[] stored_config = Storage.Split('\n'); { read_stored_settings(stored_config); } } if (drill_status == "") { drill_status = "stopped"; write_settings(); } drill_connector_status = drill_connector.Status.ToString(); Runtime.UpdateFrequency = UpdateFrequency.Update100; verify_availability(); write_settings(); }
private void DrawNormalControl(IMyTextPanel block) { Drawing drawing = new Drawing(block); StyleGauge style = new StyleGauge() { Orientation = SpriteOrientation.Vertical, Fullscreen = false, Width = 80f, Height = 200f, Padding = new StylePadding(5), RotationOrScale = 1f, Percent = false }; Vector2 position = new Vector2(drawing.viewport.Width / 2 - 100 + style.Padding.X, drawing.viewport.Height / 2 - 50 + style.Padding.Y); drawing.AddSprite(new MySprite() { Type = SpriteType.TEXT, Data = $"Airlock", Color = Color.DimGray, Position = position + new Vector2(100f, 0f), RotationOrScale = 2f, Alignment = TextAlignment.CENTER }); position += new Vector2(0, 60); drawing.DrawGauge(position, OxygenRate, 100, style, true); string icon = "No Entry"; if (OxygenRate < 1 - Epsilon) { icon = "Danger"; } drawing.AddSprite(new MySprite() { Type = SpriteType.TEXTURE, Data = $"{icon}", Color = Color.DimGray, Position = position + new Vector2(100f, 50f), Size = new Vector2(100, 100), Alignment = TextAlignment.LEFT }); if (Sleep > 0) { drawing.AddSprite(new MySprite() { Type = SpriteType.TEXT, Data = $"{Sleep}", Color = Color.DimGray, Position = position + new Vector2(150f, 120f), RotationOrScale = 2f, Alignment = TextAlignment.CENTER }); } drawing.Dispose(); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; tempDebugDisplay = GridTerminalSystem.GetBlockWithName("display1") as IMyTextPanel; permDebugDisplay = GridTerminalSystem.GetBlockWithName("display2") as IMyTextPanel; _logText = new FixedSizedQueue <string>(15); }
/// <summary> /// Sets up selected LCD for printing debug info. /// </summary> /// <param name="lcdName"></param> public void LcdSetupForDebugging(string lcdName) { IMyTextPanel lcd = getLcd(lcdName); // Seems to be unaccessible in-game :( //lcd.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.PUBLIC); }
string BlockInit() { string sInitResults = ""; gpsCenter = null; List <IMyTerminalBlock> centerSearch = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(sGPSCenter, centerSearch); if (centerSearch.Count == 0) { GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(centerSearch, localGridFilter); foreach (var b in centerSearch) { if (b.CustomName.Contains("[NAV]") || b.CustomData.Contains("[NAV]")) { gpsCenter = b; } else if (b.CustomName.Contains("[!NAV]") || b.CustomData.Contains("[!NAV]")) { continue; // don't use this one. } sInitResults = "R"; gpsCenter = b; break; } if (gpsCenter == null) { GridTerminalSystem.GetBlocksOfType <IMyShipController>(centerSearch, localGridFilter); if (centerSearch.Count == 0) { sInitResults += "!!NO Controller"; return(sInitResults); } else { sInitResults += "S"; gpsCenter = centerSearch[0]; } } } else { sInitResults += "N"; gpsCenter = centerSearch[0]; } List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); blocks = GetBlocksContains <IMyTextPanel>("[GPS]"); if (blocks.Count > 0) { gpsPanel = blocks[0] as IMyTextPanel; } if (gpsCenter == null) { Echo("ERROR: No control block found!"); } return(sInitResults); }
void StatusLog(string text, IMyTextPanel block, bool bReverse = false) { if (block == null) { return; } if (text.Equals("clear")) { block.WritePublicText(""); } else { if (bReverse) { string oldtext = block.GetPublicText(); block.WritePublicText(text + "\n" + oldtext); } else { block.WritePublicText(text + "\n", true); } // block.WritePublicTitle(DateTime.Now.ToString()); } block.ShowTextureOnScreen(); block.ShowPublicTextOnScreen(); }
private void InitDisplays() { _leftLCD = GridTerminalSystem.GetBlockWithName(LEFT_LCD) as IMyTextPanel; _rightLCD = GridTerminalSystem.GetBlockWithName(RIGHT_LCD) as IMyTextPanel; _middleLCD = GridTerminalSystem.GetBlockWithName(MIDDLE_LCD) as IMyTextPanel; _middleLCD.ShowPublicTextOnScreen(); _leftLCD.ShowPublicTextOnScreen(); _rightLCD.ShowPublicTextOnScreen(); _leftLCD.BackgroundColor = BACKGROUND_COLOR; _rightLCD.BackgroundColor = BACKGROUND_COLOR; _middleLCD.BackgroundColor = BACKGROUND_COLOR; _leftLCD.FontColor = FOREGROUND_COLOR; _rightLCD.FontColor = FOREGROUND_COLOR; _middleLCD.FontColor = FOREGROUND_COLOR; _leftLCD.Font = FONT_NAME; _rightLCD.Font = FONT_NAME; _middleLCD.Font = FONT_NAME; _leftLCD.FontSize = FONT_SIZE; _rightLCD.FontSize = FONT_SIZE; _middleLCD.FontSize = FONT_SIZE; }
private void AddEntriesToPanel(IMyTextPanel Panel) { if (Autoscroll) { List <string> buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)); buffer.AddRange(Queue); int maxLines = Math.Min(getMaxLinesFromPanel(Panel), buffer.Count); if (Prepend) { buffer.Reverse(); } Panel.WritePublicText(string.Join("\n", buffer.GetRange(buffer.Count - maxLines, maxLines).ToArray()), false); } else { if (Prepend) { var buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)); buffer.AddRange(Queue); buffer.Reverse(); Panel.WritePublicText(string.Join("\n", buffer.ToArray()), false); } else { Panel.WritePublicText(string.Join("\n", Queue.ToArray()), true); } } }
IMyTextPanel getTextBlock(string stheName) { IMyTextPanel textblock = null; List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); blocks = GetBlocksNamed <IMyTerminalBlock>(stheName); if (blocks.Count < 1) { blocks = GetMeBlocksContains <IMyTextPanel>(stheName); if (blocks.Count < 1) { blocks = GetBlocksContains <IMyTextPanel>(stheName); } } if (blocks.Count > 1) { throw new OurException("Multiple status blocks found: \"" + stheName + "\""); } else if (blocks.Count > 0) { textblock = blocks[0] as IMyTextPanel; } return(textblock); }
public void addDisplay(string name, int x, int y) { IMyTextPanel display = self.GridTerminalSystem.GetBlockWithName(name) as IMyTextPanel; initSize(display); addSurface(display as IMyTextSurface, x, y); }
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. // // It's recommended to set Runtime.UpdateFrequency // here, which will allow your script to run itself without a // timer block. Runtime.UpdateFrequency = UpdateFrequency.Update1; g = GridTerminalSystem.GetBlockWithName("Gyro") as IMyGyro; sc = GridTerminalSystem.GetBlockWithName("Cockpit") as IMyShipController; lcd = GridTerminalSystem.GetBlockWithName("LCD") as IMyTextPanel; thrusters = new List <IMyThrust>(); GridTerminalSystem.GetBlockGroupWithName("Thrusters").GetBlocksOfType <IMyThrust>(thrusters); hDamp = false; manualAlt = true; vDamp = false; targAltitude = GetAltitude(); mass = sc.CalculateShipMass().PhysicalMass; curSpeed = 0; lastHeading = sc.WorldMatrix.Forward; }
void doModeMiningOre() { List <IMySensorBlock> aSensors = null; IMySensorBlock sb; StatusLog("clear", textPanelReport); StatusLog(moduleName + ":MiningOre!", textPanelReport); Echo("current_state=" + current_state.ToString()); MyShipMass myMass; myMass = ((IMyShipController)gpsCenter).CalculateShipMass(); double effectiveMass = myMass.PhysicalMass; double maxThrust = calculateMaxThrust(thrustForwardList); Echo("effectiveMass=" + effectiveMass.ToString("N0")); Echo("maxThrust=" + maxThrust.ToString("N0")); double maxDeltaV = (maxThrust) / effectiveMass; Echo("maxDeltaV=" + maxDeltaV.ToString("0.00")); Echo("Cargo=" + cargopcent.ToString() + "%"); Echo("velocity=" + velocityShip.ToString("0.00")); Echo("#Sensors=" + sensorsList.Count); Echo("width=" + shipDim.WidthInMeters().ToString("0.0")); Echo("height=" + shipDim.HeightInMeters().ToString("0.0")); Echo("length=" + shipDim.LengthInMeters().ToString("0.0")); IMyTextPanel txtPanel = getTextBlock("Sensor Report"); StatusLog("clear", txtPanel); }
public void Main(string containerName) { IMyCargoContainer cargo = FindBlock <IMyCargoContainer>(containerName); IMyTextPanel debug = FindBlock <IMyTextPanel>("debug"); if (cargo == null || debug == null) { debug.WritePublicText("Cargo or debug not found!", false); return; } IMyInventory cargoInventory = cargo.GetInventory(0); var assemblers = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyAssembler>(assemblers); for (int i = 0; i < assemblers.Count; i++) { if (!assemblers[i].HasInventory) { continue; } IMyInventory inventory = assemblers[i].GetInventory(1); List <IMyInventoryItem> items = inventory.GetItems(); debug.WritePublicText("Items Moved:" + items.Count + "\n", true); // Move items to cargo for (int j = 0; j < items.Count; j++) { inventory.TransferItemTo(cargoInventory, 0, null, stackIfPossible: true); } } }
public DisplayPanel(List <LandingPadGroup> groups, IMyTextPanel textPanel) { Group = null; TextPanel = textPanel; PanelType = PanelType.Main; _textBuilder = new MainPanelTextBuilder(groups); }
public void LcdPrint(string msg, string lcdName = "VarPanel") { IMyTextPanel lcd = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel; lcd.WritePublicText(lcd.GetPublicText() + msg); }
private void InitializeVariables() { setupScreen = GridTerminalSystem.GetBlockWithName(setupScreenName) as IMyTextPanel; mineralsScreen = GridTerminalSystem.GetBlockWithName(mineralsScreenName) as IMyTextPanel; gasInfoScreen = GridTerminalSystem.GetBlockWithName(gasInfoScreenName) as IMyTextPanel; componentsScreens = new List <IMyTextPanel>(); componentsScreens.Add(GridTerminalSystem.GetBlockWithName(componentsScreen1Name) as IMyTextPanel); componentsScreens.Add(GridTerminalSystem.GetBlockWithName(componentsScreen2Name) as IMyTextPanel); projectorInfoScreens = new List <IMyTextPanel>(); projectorInfoScreens.Add(GridTerminalSystem.GetBlockWithName(projectionInfoScreenName1) as IMyTextPanel); projectorInfoScreens.Add(GridTerminalSystem.GetBlockWithName(projectionInfoScreenName2) as IMyTextPanel); componentDic = new Dictionary <string, Component>(); mineralDic = new Dictionary <string, Mineral>(); projector = GridTerminalSystem.GetBlockWithName(projectorName) as IMyProjector; assemblers = new List <IMyAssembler>(); outTextMinerals = new System.Text.StringBuilder(); outTextComponents = new System.Text.StringBuilder(); outTextGasInfo = new System.Text.StringBuilder(); outTextProjectiorInfo = new System.Text.StringBuilder(); mineralList = new List <Mineral>(); componentList = new List <Component>(); }
public Program() { // It's recommended to set RuntimeInfo.UpdateFrequency // Replace the Echo Echo = this.EchoToLCD; // Fetch a log text panel this._logOutput = GridTerminalSystem.GetBlockWithName("Airlock LCD") as IMyTextPanel; this.innerDoors = new List <IMyTerminalBlock>(); this.outerDoors = new List <IMyTerminalBlock>(); this.innerDoorLights = new List <IMyTerminalBlock>(); this.outerDoorLights = new List <IMyTerminalBlock>(); //this.mainVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Main") as IMyAirVent; this.purgeVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Purge") as IMyAirVent; GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door", this.innerDoors, door => door is IMyDoor); GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door", this.outerDoors, door => door is IMyAirtightHangarDoor); GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door Light", this.innerDoorLights, door => door is IMyInteriorLight); GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door Light", this.outerDoorLights, door => door is IMyInteriorLight); this.airlockState = AirlockState.Unknown; this.buttonPressed = ButtonPressed.Unknown; //Echo(innerDoors.Count.ToString()); var x = this.purgeVent.CanPressurize; }
/// <summary> /// Extracts txt info /// </summary> /// <param name="txt"></param> /// txt panel /// <returns></returns> public string GetRaw(IMyTextPanel txt) { string output; output = txt.GetPublicText(); return(output); }
void _FindConfigScreen() { int _screens = 0; List<IMyTerminalBlock> _blocks = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(_blocks); Debug("Textpanels found: " + _blocks.Count); for (int i = 0; i < _blocks.Count; i++) { Debug("Found Textpanel with name: " + _blocks[i].CustomName); if (_blocks[i].CustomName.Contains(SIOS_CONFIG_SCREEN_ID)) { Debug("Textpanels which contains SIOS_CONFIG_SCREEN_ID: " + SIOS_CONFIG_SCREEN_ID); _screens++; // there should`nt be more than 1! config = (IMyTextPanel)_blocks[i]; config.SetValue("BackgroundColor", panelDefaultBG); config.SetValue("FontColor", panelDefaultFC); config.SetValue("FontSize", 0.8f); StoreExternalConfigData(); } } if (_screens == 0) Debug("No Configscreen found"); if (_screens > 1) Debug("WARNING: TO MANY CONFIGSCREENS FOUND"); }
public DebugTools(IMyTextPanel outputDisplay) { display = outputDisplay; }
public AutoHoverController(IMyGridTerminalSystem gts, IMyProgrammableBlock pb) { Me = pb; GridTerminalSystem = gts; remote = GridTerminalSystem.GetBlockWithName(RemoteControlName) as IMyRemoteControl; gyro = GridTerminalSystem.GetBlockWithName(GyroName) as IMyGyro; if (!String.IsNullOrEmpty(TextPanelName)) screen = GridTerminalSystem.GetBlockWithName(TextPanelName) as IMyTextPanel; var list = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyGyro>(list, x => x.CubeGrid == Me.CubeGrid && x != gyro); gyros = list.ConvertAll(x => (IMyGyro)x); gyros.Insert(0, gyro); gyros = gyros.GetRange(0, GyroCount); mode = "Hover"; setSpeed = 0; }
private void init() { #region initialization oldPBName = Me.CustomName; unique_id = (new Random()).Next(); all_blocks_found = true; autopilot_en = true; location_name = "UNKNOWN"; // For spinner counter = 0; string parse = Me.CustomName.Replace(BLOCK_PREFIX, ""); int id1 = Me.CustomName.IndexOf('['); int id2 = Me.CustomName.IndexOf(']'); if (id1 >= 0 && id2 >= 0) { parse = parse.Substring(id1 + 1, id2 - id1 - 1); } else { parse = ""; } BaconArgs Args = BaconArgs.parse(parse); IS_BASE = (Args.getFlag('b') > 0); DOCK_LEFT = (Args.getFlag('l') > 0); IS_PLANET = (Args.getFlag('p') > 0); if (IS_PLANET) IS_BASE = true; List<string> nameArg = Args.getOption("name"); if (nameArg.Count > 0 && nameArg[0] != null) { location_name = nameArg[0]; } // Set all known blocks to null or clear lists lcdPanel = null; messageReceiver = null; WANProgram = null; connector = null; remoteControl = null; door = null; timer = null; landLight = null; mainGear = 0; gyros.Clear(); destinations.Clear(); gears.Clear(); // Get all blocks List<IMyTerminalBlock> blks = new List<IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix); num_blocks_found = blks.Count; // Assign blocks to variables as appropriate foreach (var blk in blks) { // LCD panel for printing if (blk is IMyTextPanel) { lcdPanel = blk as IMyTextPanel; lcdPanel.ShowPublicTextOnScreen(); lcdPanel.SetValueFloat("FontSize", 1.2f); } // Wico Area Network programmable block else if (blk is IMyProgrammableBlock && !blk.Equals(Me)) { WANProgram = blk as IMyProgrammableBlock; } // Autopilot else if (!IS_BASE && blk is IMyRemoteControl) { remoteControl = blk as IMyRemoteControl; } /* Ship or station connector for docking * Used to connect to station and for orientation info */ else if (!IS_PLANET && blk is IMyShipConnector) { connector = blk as IMyShipConnector; } /* Door used for docking; used for orientation information * since it's more obvious which way a door faces than a connector */ else if (!IS_PLANET && blk is IMyDoor) { door = blk as IMyDoor; } // Gyros for ship orientation else if (!IS_BASE && blk is IMyGyro) { IMyGyro g = blk as IMyGyro; gyros.Add(g); } // Timer block so that we can orient ship properly - requires multiple calls/sec else if (!IS_BASE && blk is IMyTimerBlock) { timer = blk as IMyTimerBlock; timer.SetValueFloat("TriggerDelay", 1.0f); } // Light (interior or spotlight) determines where we will land else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight) { landLight = blk as IMyInteriorLight; } // Landing gear.... else if (!IS_BASE && blk is IMyLandingGear) { IMyLandingGear gear = blk as IMyLandingGear; gears.Add(gear); if (gear.CustomName.ToLower().Contains("main")) { mainGear = gears.Count - 1; } } } // Make sure all gyros reset resetGyros(); // Clear block list blks.Clear(); // Get text panel blocks used by Wico Area Network for communication GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(blks, hasWANRPrefix); if (blks.Count == 0) { Echo("Error: Can't find message received text panel for Wico Area Network"); all_blocks_found = false; } else { messageReceiver = blks[0] as IMyTextPanel; messageReceiver.WritePublicTitle(""); messageReceiver.WritePrivateTitle("NAV"); } if (WANProgram == null) { Echo("Error: Can't find programming block for Wico Area Network"); all_blocks_found = false; } if (lcdPanel == null) { Echo("Error: Expect 1 LCD"); all_blocks_found = false; } if (!IS_PLANET && connector == null) { Echo("Error: Can't find any connectors to use for docking"); all_blocks_found = false; } if (!IS_BASE && remoteControl == null) { Echo("Error: Can't find any remote control blocks"); all_blocks_found = false; } if (!IS_PLANET && door == null) { Echo("Error: Can't find door"); all_blocks_found = false; } if (!IS_BASE && gyros.Count == 0) { Echo("Error: No gyros detected"); all_blocks_found = false; } if (!IS_BASE && timer == null) { Echo("Error: No timer found"); all_blocks_found = false; } if (IS_PLANET && landLight == null) { Echo("Error: No light for landing ship destination found"); all_blocks_found = false; } if (!IS_BASE && gears.Count == 0) { Echo("Warning: no landing gear found. You will not be able to land on planets"); } // Init communicator state machine comm = communicate().GetEnumerator(); // Clear autopilot state machine fly = null; #endregion }
/// <summary> /// This will find an existing TextPanelWriter for the specified IMyTextPanel, or create one if one doesn't already exist. /// </summary> public static TextPanelWriter Create(IMyTextPanel textPanel) { TextPanelWriter writer; if (TextPanelWriterCache.TryGetValue(textPanel, out writer)) { writer.Clear(); return writer; } writer = new TextPanelWriter(textPanel); TextPanelWriterCache.Add(textPanel, writer); return writer; }
void Init() { //Shift[0].x = 0; // Example for hard coded Datum Shift //Shift[0].y = 0; //Shift[0].z = 0; i++; MainScreen("init", true); Debug("", false); // Rotors on arm AR1BaseTop = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(AR1BaseTopName); // BaseTop Rotor AR2BasePole = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(AR2BasePoleName); // BasePole Rotor AR3Pole = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(AR3PoleName); // Pole Rotor AR4PoleWrist = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(AR4PoleWristName); // PoleWrist Rotor AR5WristTop = (IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(AR5WristTopName); // WristTop Rotor ARB = null;//(IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(ARBAxisName); // WristTop Rotor ARBTip = null;//(IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(ARBTipName); // WristTop Rotor ARC = null;//(IMyTerminalBlock)GridTerminalSystem.GetBlockWithName(ARCAxisName); // WristTop Rotor // Timer Block for main control loop TB = (IMyTimerBlock)GridTerminalSystem.GetBlockWithName(TBName); // ####### Optional Blocks ####### //Lighting Block for moving indication (for easy Automation usage) IL = (IMyLightingBlock)GridTerminalSystem.GetBlockWithName(ILName); // Main Screen LCD Display (for Coordinate Display) Mscreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(MscreenName); // Feed Screen LCD Display (for big display of Feed and Step Size) Fscreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(FscreenName); // easy Automation LCD Screen, Write Saved Positions to public screen (for SavePos command) AutScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(AutScreenName); if (AR1BaseTop == null) { throw new Exception("Error: AR1 BaseTop Block not found"); } if (AR2BasePole == null) { throw new Exception("Error: AR2 BasePole Block not found"); } if (AR3Pole == null) { throw new Exception("Error: AR3 Pole Block not found"); } if (AR4PoleWrist == null) { throw new Exception("Error: AR4 PoleWrist Block not found"); } if (AR5WristTop == null) { throw new Exception("Error: AR5 WristTop Block not found"); } if (TB == null) { throw new Exception("Error: Timer Block not found"); } if (Mscreen == null) { Echo("Warning: MainScreen Block not found"); } if (Fscreen == null) { Echo("Warning: FeedScreen Block not found"); } if (IL == null) { Echo("Warning: IL Arm Block not found"); } if (AutScreen == null) { Echo("Warning: easy Automation Screen Block not found"); } TargetTime = DateTime.Now.AddTicks(Zykluszeit * TimeSpan.TicksPerMillisecond); EndPosReached = 1; IstToEndInterpolIter = 5 * (SpeedUpMult - 1); // Start value for Path Speed Up ang1 = GetRotorAngle(AR2BasePole); ang2 = GetRotorAngle(AR3Pole); ang3 = GetRotorAngle(AR4PoleWrist); ang4 = GetRotorAngle(AR1BaseTop); ang5 = GetRotorAngle(AR5WristTop); MaStart = SmartAngle((ang5 - (ang4 * (-ToolDir))) * (-ToolDir)); MaEnd = MaStart; if (ARB != null) { angB = GetRotorAngle(ARB); MbStart = SmartAngle(angB); MbEnd = MbStart; } if (ARC != null) { angC = GetRotorAngle(ARC); McStart = SmartAngle(angC); McEnd = McStart; } //~ MainScreen("Ist Angles\nBasePole "+ Math.Round(ang1,3)+"\n"+ //~ "Pole "+ Math.Round(ang2,3)+"\n"+ //~ "PoleWrist "+ Math.Round(ang3,3)+"\n"+ //~ "BaseTop "+ Math.Round(ang4,3)+"\n"+ //~ "WristTop "+ Math.Round(ang5,3)+"\n", true); CalculateIstPos(ang1, ang2, ang4, ang5); //~ MainScreen("Ist Pos -> MxIst: "+r2s(MxIst)+" MyIst: "+r2s(MyIst)+" MzIst: "+r2s(MzIst), true) ; MxStart = MxIst; MyStart = MyIst; MzStart = MzIst; // Start Pos of Iteration (Start position) //~ MainScreen("iStart Pos -> MxStart: "+r2s(MxStart)+" MyStart: "+r2s(MyStart)+" MzStart: "+r2s(MzStart), true) ; MxEnd = MxIst; MyEnd = MyIst; MzEnd = MzIst; // Final Pos of Iteration MxEndOrg = MxIst; MyEndOrg = MyIst; MzEndOrg = MzIst; CalculateAngles(MxStart, MyStart, MzStart); //~ MainScreen("Start Angles\nBasePole "+ Math.Round(BasePoleAng,1) +"\n"+ //~ "Pole "+ Math.Round(PoleAng,1) +"\n"+ //~ "PoleWrist "+ Math.Round(PoleWristAng,1) +"\n"+ //~ "BaseTop "+ Math.Round(BaseTopAng,1) +"\n"+ //~ "WristTop "+ Math.Round(WristTopAng,1)+"\n",true); }
private static void ProcessLcdBlock(IMyTextPanel textPanel) { //counter++; var checkArray = (textPanel.GetPublicTitle() + " " + textPanel.GetPrivateTitle()).Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var showAll = false; bool showOre = false; bool showIngot = false; bool showComponent = false; bool showAmmo = false; bool showTools = false; bool showTest = false; // removed Linq, to reduce the looping through the array. This should only have to do one loop through all items in the array. foreach (var str in checkArray) { if (str.Equals("*", StringComparison.InvariantCultureIgnoreCase)) showAll = true; if (!showAll) { if (str.Equals("test", StringComparison.InvariantCultureIgnoreCase)) showTest = true; if (str.Equals("ore", StringComparison.InvariantCultureIgnoreCase)) showOre = true; if (str.Equals("ingot", StringComparison.InvariantCultureIgnoreCase)) showIngot = true; if (str.Equals("component", StringComparison.InvariantCultureIgnoreCase)) showComponent = true; if (str.Equals("ammo", StringComparison.InvariantCultureIgnoreCase)) showAmmo = true; if (str.Equals("tools", StringComparison.InvariantCultureIgnoreCase)) showTools = true; } } bool showHelp = !showAll && !showOre && !showIngot && !showComponent && !showAmmo && !showTools; var writer = TextPanelWriter.Create(textPanel); if (showTest) { Test(writer); writer.UpdatePublic(); return; } if (showHelp) { writer.AddPublicLine("Please add a tag to the private or public title."); writer.AddPublicLine("ie., * ingot ore component ammo tools."); writer.UpdatePublic(); return; } var buyColumn = TextPanelWriter.LcdLineWidth - 180; var sellColumn = TextPanelWriter.LcdLineWidth - 0; // This might be a costly operation to run. var markets = MarketManager.FindMarketsFromLocation(textPanel.WorldMatrix.Translation); if (markets.Count == 0) { writer.AddPublicCenterLine(TextPanelWriter.LcdLineWidth / 2f, "« Economy »"); writer.AddPublicCenterLine(TextPanelWriter.LcdLineWidth / 2f, "« No market in range »"); } else { // TODO: not sure if we should display all markets, the cheapest market item, or the closet market. var market = markets.FirstOrDefault(); // Build a list of the items, so we can get the name so we can the sort the items by name. var list = new Dictionary<MarketItemStruct, string>(); writer.AddPublicText("« Market List"); writer.AddPublicRightText(buyColumn, "Buy"); writer.AddPublicRightLine(sellColumn, "Sell »"); foreach (var marketItem in market.MarketItems) { if (marketItem.IsBlacklisted) continue; MyObjectBuilderType result; if (MyObjectBuilderType.TryParse(marketItem.TypeId, out result)) { var id = new MyDefinitionId(result, marketItem.SubtypeName); var content = Support.ProducedType(id); // Cannot check the Type of the item, without having to use MyObjectBuilderSerializer.CreateNewObject(). if (showAll || (showOre && content is MyObjectBuilder_Ore) || (showIngot && content is MyObjectBuilder_Ingot) || (showComponent && content is MyObjectBuilder_Component) || (showAmmo && content is MyObjectBuilder_AmmoMagazine) || (showTools && content is MyObjectBuilder_PhysicalGunObject) || (showTools && content is MyObjectBuilder_GasContainerObject)) // Type check here allows mods that inherit from the same type to also appear in the lists. { MyPhysicalItemDefinition definition = null; if (MyDefinitionManager.Static.TryGetPhysicalItemDefinition(id, out definition)) { list.Add(marketItem, definition == null ? marketItem.TypeId + "/" + marketItem.SubtypeName : definition.GetDisplayName()); } } } } foreach (var kvp in list.OrderBy(k => k.Value)) { writer.AddPublicLeftTrim(buyColumn - 120, kvp.Value); writer.AddPublicRightText(buyColumn, kvp.Key.BuyPrice.ToString("0.00")); writer.AddPublicRightText(sellColumn, kvp.Key.SellPrice.ToString("0.00")); writer.AddPublicLine(); } } writer.UpdatePublic(); }
private static void ProcessLcdBlock(IMyTextPanel textPanel) { //counter++; var checkArray = (textPanel.GetPublicTitle() + " " + textPanel.GetPrivateTitle()).Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var showAll = false; bool showOre = false; bool showIngot = false; bool showComponent = false; bool showAmmo = false; bool showTools = false; bool showGasses = false; bool showStock = false; bool showPrices = true; bool showTest1 = false; bool showTest2 = false; StartFrom startFrom = StartFrom.None; //if # is specified eg #20 then run the start line logic int startLine = 0; //this is where our start line placeholder sits int pageNo = 1; // removed Linq, to reduce the looping through the array. This should only have to do one loop through all items in the array. foreach (var str in checkArray) { if (str.Equals("stock", StringComparison.InvariantCultureIgnoreCase)) showStock = true; if (str.Contains("#")) { string[] lineNo = str.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); if (lineNo.Length != 0 && int.TryParse(lineNo[0], out startLine)) { //this only runs if they put a number in startFrom = StartFrom.Line; } } if (str.StartsWith("P", StringComparison.InvariantCultureIgnoreCase)) { if (int.TryParse(str.Substring(1), out pageNo)) startFrom = StartFrom.Page; } if (str.Equals("*", StringComparison.InvariantCultureIgnoreCase)) showAll = true; if (!showAll) { if (str.Equals("test1", StringComparison.InvariantCultureIgnoreCase)) showTest1 = true; else if (str.Equals("test2", StringComparison.InvariantCultureIgnoreCase)) showTest2 = true; else if (str.StartsWith("ore", StringComparison.InvariantCultureIgnoreCase)) showOre = true; else if (str.StartsWith("ingot", StringComparison.InvariantCultureIgnoreCase)) showIngot = true; else if (str.StartsWith("component", StringComparison.InvariantCultureIgnoreCase)) showComponent = true; else if (str.StartsWith("ammo", StringComparison.InvariantCultureIgnoreCase)) showAmmo = true; else if (str.StartsWith("tool", StringComparison.InvariantCultureIgnoreCase)) showTools = true; else if (str.StartsWith("gas", StringComparison.InvariantCultureIgnoreCase)) showGasses = true; } } bool showHelp = !showAll && !showOre && !showIngot && !showComponent && !showAmmo && !showTools && !showGasses; var writer = TextPanelWriter.Create(textPanel); // Use the update interval on the LCD Panel to determine how often the display is updated. // It can only go as fast as the timer calling this code is. var interval = Math.Max(1f, textPanel.GetValueFloat("ChangeIntervalSlider")); if (writer.LastUpdate > DateTime.Now.AddSeconds(-interval)) return; showPrices = !showStock || writer.IsWide; if (showTest1) { Test1(writer); writer.UpdatePublic(); return; } if (showTest2) { Test2(writer); writer.UpdatePublic(); return; } if (showHelp) { writer.AddPublicLine("Please add a tag to the private or public title."); writer.AddPublicLine("ie., * ingot ore component ammo tools."); writer.UpdatePublic(); return; } var buyColumn = TextPanelWriter.LcdLineWidth - 180; var sellColumn = TextPanelWriter.LcdLineWidth - 0; var stockColumn = TextPanelWriter.LcdLineWidth - 0; if (showPrices && showStock) { buyColumn = TextPanelWriter.LcdLineWidth - 280; sellColumn = TextPanelWriter.LcdLineWidth - 180; stockColumn = TextPanelWriter.LcdLineWidth - 0; } // This might be a costly operation to run. var markets = MarketManager.FindMarketsFromLocation(textPanel.WorldMatrix.Translation); if (markets.Count == 0) { writer.AddPublicCenterLine(TextPanelWriter.LcdLineWidth / 2f, "« {0} »", EconomyScript.Instance.ServerConfig.TradeNetworkName); writer.AddPublicCenterLine(TextPanelWriter.LcdLineWidth / 2f, "« No market in range »"); } else { // TODO: not sure if we should display all markets, the cheapest market item, or the closet market. // LOGIC summary: it needs to show the cheapest in stock(in range) sell(to player) price, and the highest (in range) has funds buy(from player) price // but this logic depends on the buy/sell commands defaulting to the same buy/sell rules as above. // where buy /sell commands run out of funds or supply in a given market and need to pull from the next market //it will either have to stop at each price change and notify the player, and/or prompt to keep transacting at each new price, or blindly keep buying until the //order is filled, the market runs out of stock, or the money runs out. Blindly is probably not optimal unless we are using stockmarket logic (buy orders/offers) //so the prompt option is the safer var market = markets.FirstOrDefault(); // Build a list of the items, so we can get the name so we can the sort the items by name. var list = new Dictionary<MarketItemStruct, string>(); writer.AddPublicCenterLine(TextPanelWriter.LcdLineWidth / 2f, market.DisplayName); if (startFrom == StartFrom.Page) { // convert the page to lines required. if (pageNo < 1) pageNo = 1; startLine = ((writer.DisplayLines - 2) * (pageNo - 1)); startFrom = StartFrom.Line; } string fromLine = " (From item #" + startLine + ".)"; writer.AddPublicText("« Market List"); if (startLine >= 1) writer.AddPublicText(fromLine); else startLine = 1; // needed for truncating end line. if (showPrices && showStock) { writer.AddPublicRightText(buyColumn, "Buy"); writer.AddPublicRightText(sellColumn, "Sell"); writer.AddPublicRightLine(stockColumn, "Stock »"); } else if (showStock) writer.AddPublicRightLine(stockColumn, "Stock »"); else if (showPrices) { writer.AddPublicRightText(buyColumn, "Buy"); writer.AddPublicRightLine(sellColumn, "Sell »"); } foreach (var marketItem in market.MarketItems) { if (marketItem.IsBlacklisted) continue; MyObjectBuilderType result; if (MyObjectBuilderType.TryParse(marketItem.TypeId, out result)) { var id = new MyDefinitionId(result, marketItem.SubtypeName); var content = Support.ProducedType(id); //if (((Type)id.TypeId).IsSubclassOf(typeof(MyObjectBuilder_GasContainerObject))) // TODO: Not valid call yet. // Cannot check the Type of the item, without having to use MyObjectBuilderSerializer.CreateNewObject(). if (showAll || (showOre && content is MyObjectBuilder_Ore) || (showIngot && content is MyObjectBuilder_Ingot) || (showComponent && content is MyObjectBuilder_Component) || (showAmmo && content is MyObjectBuilder_AmmoMagazine) || (showTools && content is MyObjectBuilder_PhysicalGunObject) || // guns, welders, hand drills, grinders. (showGasses && content is MyObjectBuilder_GasContainerObject) || // aka gas bottle. (showGasses && content is MyObjectBuilder_GasProperties)) // Type check here allows mods that inherit from the same type to also appear in the lists. { MyDefinitionBase definition; if (MyDefinitionManager.Static.TryGetDefinition(id, out definition)) list.Add(marketItem, definition == null ? marketItem.TypeId + "/" + marketItem.SubtypeName : definition.GetDisplayName()); } } } int line = 0; foreach (var kvp in list.OrderBy(k => k.Value)) { line++; if (startFrom == StartFrom.Line && line < startLine) //if we have a start line specified skip all lines up to that continue; if (startFrom == StartFrom.Line && line - startLine >= writer.WholeDisplayLines - 2) // counts 2 lines of headers. break; // truncate the display and don't display the text on the bottom edge of the display. writer.AddPublicLeftTrim(buyColumn - 120, kvp.Value); decimal showBuy = kvp.Key.BuyPrice; decimal showSell = kvp.Key.SellPrice; if ((EconomyScript.Instance.ServerConfig.PriceScaling) && (market.MarketId == EconomyConsts.NpcMerchantId)) { showBuy = EconDataManager.PriceAdjust(kvp.Key.BuyPrice, kvp.Key.Quantity, PricingBias.Buy); showSell = EconDataManager.PriceAdjust(kvp.Key.SellPrice, kvp.Key.Quantity, PricingBias.Sell); } if (showPrices && showStock) { writer.AddPublicRightText(buyColumn, showBuy.ToString("0.000", EconomyScript.ServerCulture)); writer.AddPublicRightText(sellColumn, showSell.ToString("0.000", EconomyScript.ServerCulture)); // TODO: components and tools should be displayed as whole numbers. Will be hard to align with other values. writer.AddPublicRightText(stockColumn, kvp.Key.Quantity.ToString("0.0000", EconomyScript.ServerCulture)); // TODO: recheck number of decimal places. } else if (showStock) //does this ever actually run? seems to already be in the above? { // TODO: components and tools should be displayed as whole numbers. Will be hard to align with other values. writer.AddPublicRightText(stockColumn, kvp.Key.Quantity.ToString("0.0000", EconomyScript.ServerCulture)); // TODO: recheck number of decimal places. } else if (showPrices) { writer.AddPublicRightText(buyColumn, showBuy.ToString("0.000", EconomyScript.ServerCulture)); writer.AddPublicRightText(sellColumn, showSell.ToString("0.000", EconomyScript.ServerCulture)); } writer.AddPublicLine(); } } writer.UpdatePublic(); }
void Main(string argument) { switch (argument) { case "Dampen": test = true; break; default: if (isfirst2) { //beginningvel = ship.Velocity; isfirst2 = false; } if (isfirst) { //Vector3D targ = new Vector3D(0, -60000, 0); remote = GridTerminalSystem.GetBlockWithName("Remote"); timer = GridTerminalSystem.GetBlockWithName("Timer"); ship = new SingleAxisThrustShip(remote, GridTerminalSystem, this); ship.Target = targ; isfirst = false; isfirst2 = true; panel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("LCDebug"); } //Echo(foundCenter.ToString()); // double dist = Ship.SphericalDist(remote.GetPosition(), ship.Target, foundCenter, remote.GetPosition().Length()); // double longitude = ship.GetLongitude(remote.GetPosition()) * 57.2958; // double latitude = ship.GetLatitude(remote.GetPosition()) * 57.2958; // double heading = ship.GetCurrentHeading() * 57.2958; //Vector3D kek = ship.Velocity; //ship.WriteToScreen(ship.GetDisplayString() + "\nDistance From Center: " + remote.GetPosition().Length(), "LCDebug", false); //Vector3D ForwardVel = Projection(kek, remote.WorldMatrix.Forward); // Echo(ForwardVel.Length().ToString()); Matrix orient; remote.Orientation.GetMatrix(out orient); // ship.set_oriented_gyros(new Vector3D(0, 0, 0), orient.Down); //Echo(ship.GetMassTemp().ToString()); MatrixD InvWorld = MatrixD.Invert(MatrixD.CreateFromDir(remote.WorldMatrix. Forward, remote.WorldMatrix.Forward)); // if (dist > 800) // if (ship.SetForwardVelocity_Planet(100)) test = true; //if(ship.ThrustTowardsVector(-Vector3D.Normalize(remote.GetPosition()))) timer.GetActionWithName("OnOff_Off").Apply(timer); ; } //ship.set_oriented_gyros_planet(targ, new Vector3D(0, 0, 0), orient.Right); if ((timer as IMyFunctionalBlock).Enabled) { timer.GetActionWithName("TriggerNow").Apply(timer); } }
void _FindConfigScreen() { List<IMyTerminalBlock> _configScreens = new List<IMyTerminalBlock>(); // make sure that we only gather TextPanels GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(_configScreens); int _screens = 0; Debug("Screens found:" + _configScreens.Count); for (int i = 0; i < _configScreens.Count; i++) { if (_configScreens[i].CustomName.Contains(configID)) { _screens++; // there should`nt be more than 1! config = (IMyTextPanel)_configScreens[i]; Debug("ConfigScreen found who contains the name:" + configID); Debug("External config file found! Loading DATA..."); LoadExternalConfigData(); } if (_screens == 0) { Debug("No Configscreen found"); } } }