Space Engineers

Space Engineers

36 个评价
Twinkie's Rotor(s) Controller
   
奖励
收藏
已收藏
取消收藏
Mod category: Script
文件大小
发表于
更新日期
3.892 KB
2016 年 3 月 7 日 上午 6:25
2020 年 6 月 25 日 上午 7:16
6 项改动说明 ( 查看 )

订阅以下载
Twinkie's Rotor(s) Controller

在 CptTwinkie 的 1 个合集中
Twinkie Industries™ Script Library
7 件物品
描述
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 条留言
LasrinPrime 2024 年 6 月 8 日 上午 1:57 
any way to use a single run command like "+45" so each button press advances the rotor 45 degrees?
Spaceman Spiff 2021 年 1 月 29 日 下午 2:07 
Wow! (Slaps head!!) You rock, @CptTwinkie! I don't understand why I didn't get it. :steamhappy:
CptTwinkie  [作者] 2021 年 1 月 29 日 上午 11:49 
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 2021 年 1 月 28 日 下午 3:42 
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  [作者] 2021 年 1 月 28 日 上午 11:08 
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 2021 年 1 月 27 日 下午 9:19 
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  [作者] 2019 年 12 月 15 日 上午 7:25 
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 2019 年 12 月 15 日 上午 6:50 
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 2019 年 12 月 15 日 上午 6:41 
Thanks man
CptTwinkie  [作者] 2019 年 12 月 15 日 上午 6:39 
AstroByte_YT, it's on the workshop to be shared. Use it for anything you like