Space Engineers

Space Engineers

Solar Alignment for Fixed Solar Panels
101 Comments
Mike ={JcC}= Aug 5, 2023 @ 12:10pm 
What happened to the linked mods in the description? All i get is an error from steam when clicking the links.
ZerothAngel  [author] Jul 13, 2023 @ 2:18pm 
@perahansen80
Script updated, see the July 13 entry: Change Notes
perahansen80 Jul 13, 2023 @ 2:51am 
Is there a way to make this work for sub-grid panels? I would like to use this script for my unfold-able but otherwise fixed panels.
DrBossWatson Aug 11, 2022 @ 4:11pm 
This works great for vanilla solar panels but it does not seem to work for Advanced power 2 :/
YTunz Jan 5, 2022 @ 11:54am 
Im getting an error thats saying "Caught exceptions during executions of script: An item with the same key has already been added. at" then it goes on to list a bunch of lines. For example the first one is "System.ThrowHelper.ThrowArgumentException(ExceptionResourceresource)" Any help figuring out what the problem is would be great.
Typhon Plume Nov 16, 2021 @ 4:53pm 
Will this pick up on the panels from the Advanced Power 2 mod? I been having a problem finding a script that will align them properly
Daywalker Aug 12, 2020 @ 11:59pm 
is this usable for a Station on the Moon ?
irRegularGuy646 Aug 12, 2020 @ 4:21pm 
to add on to my previous comment, it occasionally forgets to check a single axis. just now it missed roll and i had to manually roll it a bit before the script kicked in. also a command to force it to start adjusting would be cool.
irRegularGuy646 Aug 12, 2020 @ 2:32pm 
also, i've noticed that it isn't very good at correcting pitch. frequently when i turn it on (judging from the shadows) it gets the pitch wrong. i can clearly see the shadows extending forwards when if it were full efficiency the shadow would be directly underneath.
ZerothAngel  [author] Aug 11, 2020 @ 1:50pm 
It's easy enough to add a command instead of taking the old commands away and breaking builds. :P

Thanks for the idea, the script has been updated. A new command togglesolar has been added to simply toggle the state. (Note: I could not use the word toggle because it was already taken by one of my other scripts... which would cause problems with my "super scripts".)
irRegularGuy646 Aug 11, 2020 @ 1:16pm 
could you make it so that instead of "pause" and "resume" to start and stop the script, it's just one "toggle"?
Suckeychicken Jun 12, 2020 @ 5:22pm 
i may be dumb, but it wont face towards the sun in any single direction, it just moves back and forth a bit
ZerothAngel  [author] Nov 7, 2019 @ 1:03pm 
Look for these lines

public class SolarGyroController
{
private const double RunDelay = 1.0;
private const string ActiveKey = "SolarGyroController_Active";

Change RunDelay to whatever. It's the number of seconds between each update. So 0.5, 0.1, etc. would be faster. But you will probably have to scale SOLAR_GYRO_VELOCITY up to compensate as well.

No idea about the 100% vs 85% thing, but it would probably be SOLAR_GYRO_MIN_ERROR. But it's already set to 0.5%. So I've no clue where your 85% comes from, unless they changed the power output of solar panels. (I don't follow the game closely anymore...)
irRegularGuy646 Nov 4, 2019 @ 6:13pm 
how do i change it so that it updates more frequently?
irRegularGuy646 Nov 3, 2019 @ 11:48am 
how do i change it so that it will move to get 100% power instead of 85%
XyPeZ Mar 31, 2019 @ 8:23am 
Simply, amazing.
ZerothAngel  [author] Mar 10, 2018 @ 1:25pm 
This script is only for gyros. I do have one for rotors as well (single-axis only), but I admit I haven't really used it in a while, since I seldom build with rotors. I still keep it up to date though.
Smokey da Burrr Mar 9, 2018 @ 9:38pm 
Love the script! Everything working on my sattelites. I was wondering if there was a way for the script to reference a panel connected from a rotor?
HalberdGuard Feb 22, 2018 @ 1:15pm 
Thanks for the timely response! If that's how it works, I may be able to work with it : )
ZerothAngel  [author] Feb 22, 2018 @ 11:40am 
This script should work fine with only GyroControl.Yaw enabled. Or any single axis. In the past, I used only roll for some of my ships.

As for interaction with other scripts, it really depends. This script only gives up the gyroscopes when the change in max power output is small (default around .5% of the absolute max). With sun rotation, it probably won't release the gyros all that frequently.
HalberdGuard Feb 21, 2018 @ 10:08pm 
Could one remove GyroControl.Pitch and GyroControl.Roll, and leave only GyroControl.Yaw and expect the script to function accordingly? Furthermore, could one use a script that keeps a ship oriented "right-side up" on a planet along with this and expect them to play nice? Wanna make a hovering atmospheric base with a vertical, front-to-back solar sail, such that the whole ship will stay upright and point one or the other of its sides to the star.
Эльфик Jan 10, 2018 @ 9:26am 
const float SOLAR_GYRO_VELOCITY = 0.051f; // In radians per second
Stray Jan 10, 2018 @ 8:08am 
I've been looking through the code and my unexperienced eyes were unable to find a limiter to how fast the station will move, granted I love the code and will continue to use it. but ever 30 odd seconds the station dramatically swivells towards the sun and I can already foresee some dents and scrapes. Any help is appreicated
Эльфик Dec 16, 2017 @ 11:52am 
good work. how about to make full roll in case of Power<25%, to fix partially exposed panels issue? better optional for different cases. please
Raziel Dec 2, 2017 @ 4:52pm 
thank you. Because the solarpanels on the botom of the ship.^^
ZerothAngel  [author] Dec 2, 2017 @ 4:46pm 
This version can align on all 3 axes. It requires a minor code edit, I've updated the description with instructions.

I'm not quite sure how solar panels with pistons would work. Got a picture or something?

I also have a (1-axis) rotor controller for solar panels, but I'm sure others have done that better.
Raziel Dec 2, 2017 @ 4:21pm 
Nice. Do you can build an expandet version wich can handle 3 Axes (pitch roll yaw) and solarpannels on Pistons?
JR_Ewing Sep 7, 2017 @ 8:45am 
I have tried your script on small scoutship and worked great. But If Iam trying to apply a script to my almost finished "pilgrim base" ship, the ship is rotation in quit high speed no meeter where is sun. My ship has its own solar panels, but also has additional foldable panels over rotors - all oriented same direction fully deployed. I cant see a solution of this issue.

https://steamuserimages-a.akamaihd.net/ugc/868488441779258277/C90E9387840366038567116538E47E9517B8507E/
ZerothAngel  [author] Jul 30, 2017 @ 10:19am 
Been working since February of last year, first through a hackish workaround (parsing DetailedInfo) and then they finally added back what was needed.
Krypt Jul 30, 2017 @ 6:36am 
So. Now, after 2 years, it working again? :)
ZerothAngel  [author] Jun 21, 2017 @ 4:23pm 
The script will fail if there's absolutely no light falling on any of your solar panels.

Otherwise make sure you have a reference set up so yaw & pitch are correct for your ship.
Necrolet Jun 21, 2017 @ 1:10pm 
Never mind, solved it. Now it seems my ship's left side is always facing the sun... Any ideas?
ZerothAngel  [author] Jun 21, 2017 @ 11:28am 
Any error messages from the prog block?

Otherwise that usually means there's a timer block issue. Make sure it runs the prog block with no argument and then "starts" itself.
Necrolet Jun 21, 2017 @ 11:18am 
My ship keeps rotating nonstop regardless the sun position...
ZerothAngel  [author] Jun 9, 2017 @ 10:28am 
I'm not really into UIs for my scripts.

What sort of things would be useful that Automatic LCDs doesn't already provide?
Skallabjorn Jun 9, 2017 @ 6:31am 
anyway to get this to show a status on an lcd screen?
Xanthyn May 31, 2017 @ 4:59am 
Heya, sorry to spam your workshop, but it wouldn't let me comment you directly. Just letting you know that in my own upload, I have credited you for your work on this script, here's a workshop link: http://steamcommunity.com/sharedfiles/filedetails/?id=936622135
Thanks for making this script!
BLUNT May 21, 2017 @ 9:23am 
Hi ZerothAngel!

This is a great script! Would you please upload a separate 3 axis version?
I've found it useful if the satellite gets nudged or takes a small hit.

To answer the previous question, yes it works on a 10 sec timer no problem. :steamhappy:
Xanthyn Apr 27, 2017 @ 8:41pm 
Awesome, thanks ZerothAngel! Based on the testing that I've done, it looks like it works OK with a slower timer. I only asked because I haven't actualy tried letting it sit for a few hours/days and seeing what happens.
ZerothAngel  [author] Apr 27, 2017 @ 7:28pm 
Does it work with a slower timer? I'm actually not sure. Though I just noticed this script doesn't control the timer block like my other scripts, so maybe it does.

Not sure about optimizations, this script pretty much only does one thing.

And yeah, the workshop thing is cool. Thanks for letting me know!
Xanthyn Apr 27, 2017 @ 6:09pm 
Thanks so much Zeroth! That easy. Do you have any suggestions for code blocks I should remove/tweak to optimize for a slower timer and for use on a stationary satellite with no thrusters? I plan on printing these en masse so I figure any little performance save is a good thing.

I plan on doing a workshop release for a build that uses this script in the next few days (unless you object). I'll of course include your name, a link to this page, and give full credit to you for this script - please let me know if you prefer that I not do so. Thanks!
ZerothAngel  [author] Apr 27, 2017 @ 5:50pm 
I guess switching it to 3-axis isn't very user-friendly anymore (or maybe it never was).

Look for this part of the code, it's not far down:

private readonly SolarGyroController solarGyroController =
new SolarGyroController(
GyroControl.Pitch,
GyroControl.Roll
);

and make it look like this:

private readonly SolarGyroController solarGyroController =
new SolarGyroController(
GyroControl.Yaw,
GyroControl.Pitch,
GyroControl.Roll
);

Basically, you just add "GyroControl.Yaw," in there.
Xanthyn Apr 27, 2017 @ 4:48pm 
I am really liking this script so far - I just have one question - how do I enable 3 axis control for the script? Thanks for this great tool!
Overheal Apr 6, 2017 @ 12:49am 
This is the plug and play script I've been trying to find for *days*, that doesn't require special naming schemes or rotors and stuff. Thank you!
ZerothAngel  [author] Mar 14, 2017 @ 7:26pm 
I would set up the reference group on a properly-oriented block (station, remote control, cockpit, etc.) anyway since it's so easy to do.

The only other way I know of figuring out the grid orientation is to enable displaying of the grid axes. But that assumes you can see the axes somewhere (they're not buried deep in your ship) and you know what colors correspond to what direction... offhand, I don't know what that is.

And in case I answered something else entirely: the yaw, pitch, & roll used by the script is based on what the script thinks is "forward" and "up" on your ship. If those directions don't align with how you normally fly your ship, then your solar panels probably won't line up correctly, especially if you have solar panels on a single plane.
cy-one Mar 14, 2017 @ 5:01pm 
Can you explain how this reference thing works? How do I know (without the solar gyro reference thing) where "up" and "front" is?
ZerothAngel  [author] Feb 11, 2017 @ 10:35am 
I checked it out and it's because they changed the type of the newly-added "CenterOfMass". I haven't seen any announcements about it and I'm not sure what direction they'll be going for the next stable.

But this should work on 01.174:
https://tyrannyofheaven.org/ZerothAngel/SEScripts/Solar%20Alignment/Script.cs
ZerothAngel  [author] Feb 11, 2017 @ 9:48am 
Well, that's still worrying. Wonder they broke this time...

Anyway, thanks for letting me know.
TuSlayer Feb 11, 2017 @ 9:42am 
ya, it the dev version sorry about that.
ZerothAngel  [author] Feb 11, 2017 @ 9:37am 
What version of the game?