Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
2) no, you don't need to change any of that. only change that true to false as I suggested
3) after the rotation finishes, just call the script with no argument and it will perform the stop function, freeing your rotors for whatever the other thing is
//Loop through each rotor on the list
for (int i = 0; i < listRotors.Count; i++)
{
float setVelocity = 0f;
if (listRotors .RotorLock)
listRotors .RotorLock = false;
float curAngle = RadiansToDegrees(listRotors .Angle);
if (curAngle == setAngle)
return;
setVelocity = (curAngle < setAngle) ? (float)desiredVelocity : -(float)desiredVelocity;
//Set the appropriate limit
if (setVelocity > 0)
listRotors .UpperLimitRad = DegreesToRadians(setAngle);
else
listRotors .LowerLimitRad = DegreesToRadians(setAngle);
//Set the velocity
listRotors .SetValue<float>("Velocity", setVelocity);
}
Stop(); <== ADDED
}
Help?
void Stop()
{
//Loop through each rotor on the list
for (int i = 0; i < listRotors.Count; i++)
{
//Setting the angles to more than 360 sets them to unlimited <--- read
listRotors .SetValue<float>("LowerLimit", -361f);
listRotors .SetValue<float>("UpperLimit", 361f);
//Set velocity to 0
listRotors .SetValue<float>("Velocity", 0f);
//Lock
listRotors .RotorLock = true; <--- this guy here controls the lock, set it to false
}
}
That your script has nothing to do with lights, i know. I was like to add this function. I use your script for opening and closing a big door and my idea was that a light turns red when the rotors are moving and when they are stoping it turns again white or turns off. I think now, with your script ver 1.3 or 1.2 was not possible. With the new one 1.4, i don't know, if my idea is possible with your script.
You have to wait until the rotors finish turning, then set the argument to empty (nothing) or the velocity to 0 and run it again. That will lock the rotors.
Also, it has nothing to do with lights so I'm not sure what you're trying to do with those.
i have another question. I noticed that your skript don't run until the end. The rotors are stopping moving but only because of the set upper or lower limit. After running the skript i see, that the velocity is still set and the rotor is not locked. I think correct should be, that the rotors are locked after running.
I was like to control also some lights with your skripts, but it was not working, that's why i saw.
is this script still working? In the past I used it and it was working fine and i liked very much. When i run it now it tells me "index was out of the bounds of the array". Can you help?
Another option I'm gonna try is to update this guys Universal Rotor and Piston Sync script so that it runs with the current API https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=404120497
Most of my couple years training and practice are in C++, but writing little snippets of C# to make things do fun stuff in SE seems like a good way to gently start learning some C#
This situation is not really ideal. I would recommend checking out the hinge mod. I have a script for that as well. The idea is that the hinges would both face the same direction and move to the same angles. That way you can set them both from a single PB using my hinge script. The advantage here would be that you could pass any angle into the script to achieve fine control.
https://www.youtube.com/watch?v=w03cTM35SaY
void Main()
{
List<IMyTerminalBlock> blocklist;
blocklist = new List<IMyTerminalBlock>();
GridTerminalSystem.SearchBlocksOfName("Rotor 1b", blocklist);
blocklist[0].SetValue("LowerLimit",(float)-361);
blocklist[0].SetValue("UpperLimit",(float)361);
GridTerminalSystem.SearchBlocksOfName("Rotor 2b", blocklist);
blocklist[0].SetValue("LowerLimit",(float)-361);
blocklist[0].SetValue("UpperLimit",(float)361); }
rotor.SetValue("LowerLimit",(float)-361);
rotor.SetValue("UpperLimit",(float)361);
thanks
this means i can have my artillery have pre-set fireing angles at every 5 degrees?