Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string soundBlockKeyword = "gravity";
- public bool inGravity = false;
- public List<IMyShipController> controllerList = new List<IMyShipController>();
- public List<IMySoundBlock> soundBlockList = new List<IMySoundBlock>();
- public Program()
- {
- Runtime.UpdateFrequency = UpdateFrequency.Update100;
- }
- public void Main(string argument)
- {
- if (argument.Length > 0)
- {
- Echo("Testing alarm");
- SoundAlarm();
- }
- controllerList.Clear();
- GridTerminalSystem.GetBlocksOfType<IMyShipController>(controllerList);
- if (controllerList.Count > 0)
- {
- double gravity = controllerList[0].GetNaturalGravity().Length();
- Echo($"Current Gravity: {(gravity / 9.81).ToString("N2")}%");
- if (!inGravity && gravity > 0.0)
- {
- inGravity = true;
- SoundAlarm();
- }
- else if (inGravity && gravity == 0.0)
- inGravity = false;
- }
- }
- public void SoundAlarm()
- {
- soundBlockList.Clear();
- string lowerSoundKeyword = soundBlockKeyword.ToLower();
- GridTerminalSystem.GetBlocksOfType<IMySoundBlock>(soundBlockList, b => b.CustomName.ToLower().Contains(lowerSoundKeyword));
- for (int i = 0; i < soundBlockList.Count; i++)
- {
- if (soundBlockList[i].IsSoundSelected) soundBlockList[i].Play();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement