Space Engineers

Space Engineers

76 ratings
Solar Alignment for Fixed Solar Panels
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
404.258 KB
21 Jul, 2015 @ 10:38pm
13 Jul, 2023 @ 2:12pm
15 Change Notes ( view )

Subscribe to download
Solar Alignment for Fixed Solar Panels

Description
2017-11-17 Update: No longer needs a timer block. If you had one before, I recommend you "disconnect" it from the prog block (remove all its actions) to reduce surprises.

This script keeps your ship's (fixed) solar panels aligned with the sun by manipulating its gyros.

Main Features
  • Works with any number of axes. By default, operates on pitch and roll.

  • Adapts to any number of gyros installed in any orientation. Only touches gyros on the same grid as its programmable block though, so it won't touch gyros on ships connected via connector. (But ships connected via merge blocks are considered the same ship, so keep that in mind...)

  • Can easily be paused & resumed by running the programmable block with an argument. This allows you to take full control of your ship again.
This script is a cut-down version of that which I normally run on my satellites, mobile platforms, jump rings/sleds, etc. so it's had a lot of use & testing (as much as a single person can :P). I also use it on my 3200 tonne survival ship, though with just a single axis (roll).

Setup
Just load it into a programmable block. It will start running right away (no timer block required).

The Reference Point
The script by default operates on pitch and roll. But this is "pitch" and "roll" relative to the ship's grid pivot. If the axes are wrong on your ship (this can happen easily if you're in survival and build from a wrongly-aligned projector), then you can do one of two things: edit the code and change the axes to your liking, or create a group named SolarGyroReference that contains exactly 1 block. It can be any kind of block, but the "front" and "up" sides of this block will be used as your ship's "front" and "up." So the best block to use as reference is a remote control or other ship controller block, like a cockpit or flight seat.

If you add or change the reference group, be sure to re-compile the script so it picks up the new reference block.

Commands
You can optionally send the script's programmable block one of two arguments (e.g. from your cockpit toolbar or a button panel or a sensor):
  • pause - This will pause the script and allow you to rotate your ship normally using the mouse/keyboard etc.

  • resume - This will resume the script's behavior.

  • togglesolar - This will toggle the script's state between active & paused.

3-Axis Alignment
Unfortunately, there's no one-stop option for this, but you can make the script align all 3 axes by looking for the following:
private readonly SolarGyroController solarGyroController = new SolarGyroController( GyroControl.Pitch, GyroControl.Roll );

and adding "GyroControl.Yaw," like so (don't forget the comma):

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

LCD Output

See this post.
101 Comments
Mike ={JcC}= 5 Aug, 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] 13 Jul, 2023 @ 2:18pm 
@perahansen80
Script updated, see the July 13 entry: Change Notes
perahansen80 13 Jul, 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 11 Aug, 2022 @ 4:11pm 
This works great for vanilla solar panels but it does not seem to work for Advanced power 2 :/
YTunz 5 Jan, 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 16 Nov, 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 12 Aug, 2020 @ 11:59pm 
is this usable for a Station on the Moon ?
irRegularGuy646 12 Aug, 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 12 Aug, 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] 11 Aug, 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".)