public void doUpdates() { Single slider = screen.GetProperty <Single>("ChangeIntervalSlider"); if (slider < 5) { menu.Up(); screen.SetProperty <Single>("ChangeIntervalSlider", (Single)5); } if (slider > 5) { menu.Down(); screen.SetProperty <Single>("ChangeIntervalSlider", (Single)5); } Single delay = timer.GetProperty <Single>("TriggerDelay"); if (delay > 5) { menu.Choose(); timer.SetProperty <Single>("TriggerDelay", (Single)5); } if (delay < 5) { menu.Back(); timer.SetProperty <Single>("TriggerDelay", (Single)5); } lcd.clear(); lcd.update(); lcd.SetText(menu.Draw()); }
public AttackDetector(StorageSetter storage, IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { ammo = VRage.MyFixedPoint.DeserializeStringSafe(storage.getStorage()); turrets = Blocks.InGroupsNamed("Turrets"); log = new EasyLCD(Blocks.Named("LCD Panel Attacks Log")); beacon = Blocks.InGroupsNamed("Beacon Attack Detector").GetBlock(0); this.storage = storage; Every(5 * EasyAPI.Seconds, doWork); On("clear", delegate() { log.SetText(""); beacon.SetName("Beacon Attack Detector"); }); }
public void doWork() { VRage.MyFixedPoint newAmmo = turrets.Items().OfType("NATO_25x184mm").Count(); newAmmo = newAmmo + turrets.Items().OfType("Missile200mm").Count(); if (newAmmo < ammo) { string timestamp = DateTime.UtcNow.AddHours(3).ToString("dd.MM.yyyy HH:mm:ss"); log.SetText("[" + timestamp + "] Attack detected, fired " + (ammo - newAmmo) + " ammo; Remaining: " + newAmmo + "\n" + log.screen.GetPublicText()); beacon.SetName("!!! Attack detected at " + timestamp + " !!!"); } ammo = newAmmo; storage.setStorage(ammo.ToString()); }
// Runs every 100 milliseconds public void doUpdates() { // Get value of change interval slider from LCD screen Single slider = screen.GetProperty <Single>("ChangeIntervalSlider"); if (slider < 5) { menu.Up(); screen.SetProperty <Single>("ChangeIntervalSlider", (Single)5); } if (slider > 5) { menu.Down(); screen.SetProperty <Single>("ChangeIntervalSlider", (Single)5); } // Get value of trigger delay from timer block Single delay = timer.GetProperty <Single>("TriggerDelay"); if (delay > 5) { menu.Choose(); timer.SetProperty <Single>("TriggerDelay", (Single)5); } if (delay < 5) { menu.Back(); timer.SetProperty <Single>("TriggerDelay", (Single)5); } // Clear LCD and display menu lcd.clear(); lcd.update(); lcd.SetText(menu.Draw(70, 7)); }
public void doUpdates() { lcd.clear(); lcd.update(); lcd.SetText(menu.Draw()); }