Space Engineers

Space Engineers

Not enough ratings
Solar Tracker
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
361.468 KB
4 Jan, 2015 @ 4:25pm
5 Jan, 2015 @ 7:25pm
3 Change Notes ( view )

Subscribe to download
Solar Tracker

Description
This code will attempt to orient a ship via its gyros so its solar panels can provide maximum power.

There are two caveats: all solar panels should only have one side exposed OR all solar panels should have both sides equally exposed.

To use this, make sure your ship has at least one solar panel, at least one gyro, a timer and a trigger block. Configure the trigger to run the code, and also to ‘Trigger now’ on itself.

It mostly works via trial and error and will go through a number of states, starting with rotating along 2 axis at random and then going along each direction from there.

If it cannot reach its target power output (currently set at 85% of maximum solar output), it will begin again until it has satisfied this requirement.

If the panels are more or less perpendicular to the sun the power values won’t change, so as a safeguard the ship will only complete a single full rotation (if it is able to, gyro power dependent) before continuing on.

Finally, if when the program runs for the first time it senses that it is already at or above its target power threshold, it will not switch states.
16 Comments
ArturTheLord 3 Aug, 2019 @ 10:47am 
you
Fi77on 15 Feb, 2017 @ 12:22pm 
Has this script been fixed yet?
Ivar418 14 Jun, 2016 @ 9:25am 
plz fix this
[MTX]Rooster 6 Feb, 2016 @ 9:52am 
Having a problem with this.. I have one side covered of my panels (well armor block frames, meaning not filled in, but the led status on panel shows all red meaning the blocks are blocking that side of the panel) but the script still insists on aiming the red/covered side at the sun. Even if I manually turn the ship so all panels are 4xled full power, it still turns them to the back side where they are all red. Is there a toggle in the script for which side of the panels is the 'front' side or something I can tweak? It's certainly not aiming the panels based on the most powerful input.. lol as it's turning them to make them all red.. (no power input)
[MTX]Rooster 2 Feb, 2016 @ 11:46am 
TY dorsai3d - I have been fighting with my prog block and timer for days trying to get this script to work - It did nothing... replaced the top line of code (4 or 5 lines I think) with yours and seems to work! (still seems to move too much, even when aiming dead on at sun) but at least it's working now! :)
damienmccain12 14 Jan, 2016 @ 8:08pm 
it cant find my antenna ,any thoughts?
dorsai3d 13 Nov, 2015 @ 7:29pm 
Wiseguy pointed out the issue, but I want to clarify:
The script tries to load solar panels and gyros into the same List. This now causes the gyro blocks to overwrite the solar panel blocks and breaks the script. Changing the first few lines to this solved the problem:
var blocks = new List<IMyTerminalBlock>();
var GyroBlocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMySolarPanel>(blocks);
GridTerminalSystem.GetBlocksOfType<IMyGyro>(GyroBlocks);
blocks.AddRange(GyroBlocks);
Wiseguy 19 Oct, 2015 @ 4:29am 
I've tried it last week, in my case it needed a small change but after that it worked :)

In the main()-method it requests all the solar panels and all the gyros. For some reason this did not work in my game, so I requested a list of all the solar panels and a separate list of all gyros, and List<T>.AddRange()'d them together.
Greatheart 16 Jul, 2015 @ 8:11am 
Does this still work? I'm running it and the beacon is re-named to "State: 0, Power: NaN%". So I guess the script is running but something isn't working. I have a gyro, default solar panel, programmable block, timer block etc.
Azrael 10 Jan, 2015 @ 3:46pm 
Very nice script!
It would be nice, if the script would deactivate the gyro-override at the end, so that you're able to move your ship again =)
Or is it that, what you meant with "gyro-override issues" ?