Space Engineers

Space Engineers

36 ratings
Twinkie's Rotor(s) Controller
   
Award
Favorite
Favorited
Unfavorite
Mod category: Script
File Size
Posted
Updated
3.892 KB
7 Mar, 2016 @ 6:25am
25 Jun, 2020 @ 7:16am
6 Change Notes ( view )

Subscribe to download
Twinkie's Rotor(s) Controller

In 1 collection by CptTwinkie
Twinkie Industries™ Script Library
7 items
Description
Twinkie Industries™ Automation Presents
Rotor(s) Controller v1.5

This script will allow you to add as many rotors as you like and then control their angles
in one easy step.

* Add the rotor(s) you want to control to the script
* Pass the desired angle using the run argument.

When you run the script the rotors will move to the desired angle. If you run it without an angle it will stop and lock the rotors.

Code:
https://pastebin.com/5wxPEs1y
50 Comments
LasrinPrime 8 Jun, 2024 @ 1:57am 
any way to use a single run command like "+45" so each button press advances the rotor 45 degrees?
Spaceman Spiff 29 Jan, 2021 @ 2:07pm 
Wow! (Slaps head!!) You rock, @CptTwinkie! I don't understand why I didn't get it. :steamhappy:
CptTwinkie  [author] 29 Jan, 2021 @ 11:49am 
1) it's C#
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
Spaceman Spiff 28 Jan, 2021 @ 3:42pm 
I appreciate the response and recommendation. Sadly, I am a neophyte when it comes to C++, so I'm lost where I should make the Stop(); call. I tried here, but it didn't work, i.e., the program doesn't do anything when it's called, so obviously I screwed it up.

//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?
CptTwinkie  [author] 28 Jan, 2021 @ 11:08am 
Just taking a quick look at the stop function i would say change the lock to false and call that to set your unlimited values

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
}
}
Spaceman Spiff 27 Jan, 2021 @ 9:19pm 
I've built a deployable solar array with hinges, and solar rotors to work with Isy's Solar Alignment Script. The rotors rotate to the stow or deploy positions fine, but are left with angle settings still set whereas Isy's script wants "unlimited" on both ends to properly find the optimum angles. Is there a way to reset the rotor angles back to "unlimited" after your script runs, other than to cycle the increase/decrease angle command for the rotors using a timer block a bunch of times?
CptTwinkie  [author] 15 Dec, 2019 @ 7:25am 
The art of programming is managing complexity. Anyone can make code that works, but it takes dedication and experience to make code that is elegant.
Morphyxx 15 Dec, 2019 @ 6:50am 
I just wanna say that yours worked first try and is one of the best rotor scripts out there. Every other one is SUPER frigin complicated but yours was way easier to understand. So i just wanna say thank you for this script and im going to link your work in the description of the world when im done with it.
Morphyxx 15 Dec, 2019 @ 6:41am 
Thanks man
CptTwinkie  [author] 15 Dec, 2019 @ 6:39am 
AstroByte_YT, it's on the workshop to be shared. Use it for anything you like