752692769 752692769
关注数: 65 粉丝数: 102 发帖数: 9,514 关注贴吧数: 111
发现一个不错的MOD http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fsteamcommunity.com%2Fsharedfiles%2Ffiledetails%2F%3Fid%3D373853810%26searchtext%3D&urlrefer=16c2dc9f2000f4137bc486ba3d25c944重生船类 用连接块连接的机体 亮点是尾部是独立部件可以自己运作 有电池,两个小喷口,一个天线 上面的编程模块脚本看不懂,似乎是自动充电 以拆了喷口, 上了摄像头 远程遥控收集器和加特林机枪 @ 神葬的右手 /* /* Script for automatic rotor stop when a solar panel has high power output. Version: 0.8 Sigurd */ const byte HighPwrValue = 15; // Set this to your minimum power requirement per panel. const string NameOfSolar = "Solarx"; // Search for Solar Blocks with this name. const string NameOfRotor = "Rotorx"; // Search for Rotor Blocks with this name. const bool EnableTimerMgmt = true; // Enable Dynamic Timer Trigger Management for better accuracy and performance. const string NameOfTimer = "Timerx"; // Set this to the timer responsible for triggering this program. const bool EnableAdvRotorMgmt = true; // Enable Advanced Rotor Management [ Experimental ] void Main() { List<IMyTerminalBlock> solarBlocks = new List<IMyTerminalBlock>(); List<IMyTerminalBlock> rotorBlocks = new List<IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(NameOfSolar, solarBlocks); // Search for Solar Blocks GridTerminalSystem.SearchBlocksOfName(NameOfRotor, rotorBlocks); // Search for Rotor Blocks var timer = GridTerminalSystem.GetBlockWithName(NameOfTimer) as IMyTimerBlock; int count = solarBlocks.Count; // Counts all solar blocks int rcount = rotorBlocks.Count; // Counts all rotor blocks bool[] rotorsw = new bool[rcount]; // Will store True/False on each rotor bool[] rotorturn = new bool[rcount]; // Will store True/False on each rotor float pwr; // Stores current power. Needs to be a floating point number float LastPwr; // Stores last runs power for(int i = 0; i < count; i++) { IMySolarPanel solar = solarBlocks[i] as IMySolarPanel; // I am a Solar Panel if(solar != null) { // Yes I am float.TryParse(solar.DetailedInfo.Substring(30,4), out pwr); // Get power into variable. Might break in future updates if (solar.DetailedInfo.Substring(31,5).Contains(" W")) { pwr /= 1000; } // Make sure power is in kW if (EnableAdvRotorMgmt) { string[] words = solar.CustomName.Split(':'); // Colon split words if (words.Length > 1) {// If more than one word if (!float.TryParse(words[1], out LastPwr)) { LastPwr = 0;} rotorturn[i] = (LastPwr <= pwr) ? false : true; } solar.SetCustomName(words[0] + ":" + pwr); } rotorsw[i] = (pwr <= HighPwrValue) ? true : false; // Do we have enough juice? } } bool containsFalse = false; for(int i = 0; i < rcount; i++) { IMyMotorStator rotor = rotorBlocks[i] as IMyMotorStator; // I am a Rotor if(rotor != null) { // Yes I am if (rotorsw[i] == false) { // Do I have enough juice rotor.GetActionWithName("OnOff_Off").Apply(rotor); // Stop rotor } else { rotor.GetActionWithName("OnOff_On").Apply(rotor); // Start rotor containsFalse = true; if (EnableAdvRotorMgmt && rotorturn[i]) { rotor.GetActionWithName("Reverse").Apply(rotor); } } } } if (containsFalse && EnableTimerMgmt) { if (timer.TriggerDelay >= 8) { AdjustTriggerDelay(timer, false, 3); // Decrease Timer Trigger Delay } if (timer.TriggerDelay > 2) {// BUG if TriggerDelay == 1 ? AdjustTriggerDelay(timer, false, 1); // Decrease Timer Trigger Delay } } else { if (timer.TriggerDelay <= 8 && EnableTimerMgmt) { AdjustTriggerDelay(timer, true, 1); // Increase Timer Trigger Delay } } } void AdjustTriggerDelay(IMyTimerBlock timer, bool Direction, byte Iteration) { for (byte i = 0; i < Iteration; i++) { if (Direction) { timer.GetActionWithName("IncreaseTriggerDelay").Apply(timer); }// Increase Timer Trigger Delay else { timer.GetActionWithName("DecreaseTriggerDelay").Apply(timer); }// Decrease Timer Trigger Delay } } Script for automatic rotor stop when a solar panel has high power output. Version: 0.8 Sigurd */ const byte HighPwrValue = 15; // Set this to your minimum power requirement per panel. const string NameOfSolar = "Solarx"; // Search for Solar Blocks with this name. const string NameOfRotor = "Rotorx"; // Search for Rotor Blocks with this name. const bool EnableTimerMgmt = true; // Enable Dynamic Timer Trigger Management for better accuracy and performance. const string NameOfTimer = "Timerx"; // Set this to the timer responsible for triggering this program. const bool EnableAdvRotorMgmt = true; // Enable Advanced Rotor Management [ Experimental ] void Main() { List<IMyTerminalBlock> solarBlocks = new List<IMyTerminalBlock>(); List<IMyTerminalBlock> rotorBlocks = new List<IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(NameOfSolar, solarBlocks); // Search for Solar Blocks GridTerminalSystem.SearchBlocksOfName(NameOfRotor, rotorBlocks); // Search for Rotor Blocks var timer = GridTerminalSystem.GetBlockWithName(NameOfTimer) as IMyTimerBlock; int count = solarBlocks.Count; // Counts all solar blocks int rcount = rotorBlocks.Count; // Counts all rotor blocks bool[] rotorsw = new bool[rcount]; // Will store True/False on each rotor bool[] rotorturn = new bool[rcount]; // Will store True/False on each rotor float pwr; // Stores current power. Needs to be a floating point number float LastPwr; // Stores last runs power for(int i = 0; i < count; i++) { IMySolarPanel solar = solarBlocks[i] as IMySolarPanel; // I am a Solar Panel if(solar != null) { // Yes I am float.TryParse(solar.DetailedInfo.Substring(30,4), out pwr); // Get power into variable. Might break in future updates if (solar.DetailedInfo.Substring(31,5).Contains(" W")) { pwr /= 1000; } // Make sure power is in kW if (EnableAdvRotorMgmt) { string[] words = solar.CustomName.Split(':'); // Colon split words if (words.Length > 1) {// If more than one word if (!float.TryParse(words[1], out LastPwr)) { LastPwr = 0;} rotorturn[i] = (LastPwr <= pwr) ? false : true; } solar.SetCustomName(words[0] + ":" + pwr); } rotorsw[i] = (pwr <= HighPwrValue) ? true : false; // Do we have enough juice? } } bool containsFalse = false; for(int i = 0; i < rcount; i++) { IMyMotorStator rotor = rotorBlocks[i] as IMyMotorStator; // I am a Rotor if(rotor != null) { // Yes I am if (rotorsw[i] == false) { // Do I have enough juice rotor.GetActionWithName("OnOff_Off").Apply(rotor); // Stop rotor } else { rotor.GetActionWithName("OnOff_On").Apply(rotor); // Start rotor containsFalse = true; if (EnableAdvRotorMgmt && rotorturn[i]) { rotor.GetActionWithName("Reverse").Apply(rotor); } } } } if (containsFalse && EnableTimerMgmt) { if (timer.TriggerDelay >= 8) { AdjustTriggerDelay(timer, false, 3); // Decrease Timer Trigger Delay } if (timer.TriggerDelay > 2) {// BUG if TriggerDelay == 1 ? AdjustTriggerDelay(timer, false, 1); // Decrease Timer Trigger Delay } } else { if (timer.TriggerDelay <= 8 && EnableTimerMgmt) { AdjustTriggerDelay(timer, true, 1); // Increase Timer Trigger Delay } } } void AdjustTriggerDelay(IMyTimerBlock timer, bool Direction, byte Iteration) { for (byte i = 0; i < Iteration; i++) { if (Direction) { timer.GetActionWithName("IncreaseTriggerDelay").Apply(timer); }// Increase Timer Trigger Delay else { timer.GetActionWithName("DecreaseTriggerDelay").Apply(timer); }// Decrease Timer Trigger Delay } } 麻烦看看脚本!能的话全周天浮游炮就诞生了
1 下一页