Space Engineers

Space Engineers

Nightlight - Automatic light switching during day/night
43 Comments
BooseOG 1 Nov, 2024 @ 7:14am 
just use a event controller
erik 16 Feb, 2024 @ 12:36pm 
good evening no longer works an update maybe
Demonik 15 Nov, 2023 @ 1:33am 
@ Commander Rotal I have the same error now too. Did you end up fixing it?
Capt Fuzzy 19 Jan, 2023 @ 5:33pm 
I don't think this is working...
Either I'm just not understanding how this works or the setup instructions are lacking in a proper explanation of what to do and how to do it.
It doesn't seem to be working though, at least not as far as I can tell, anyway.
I'm getting no compiling errors, or errors that I can see, period.

Some of my questions:
What exactly is 'light strength'? Is it a factor of energy output in some way?
Where does the prefix go? On every light that you want controlled?
Will this work with groups of lights?
When setting up the triggers in the timer block, does it matter what order they are in, i.e., timer block first then PB, or vice-versa?
Commander Rotal 3 Feb, 2020 @ 11:27am 
I don't think i've messed with that; last thing i tried was just placing down a completely new setup (new Solar Panel, new Programmable Block etc); first i just checked if it worked without the NL prefix; same error message. Then i tried with the NL prefix as usual; same result.
ThatsEli  [author] 3 Feb, 2020 @ 11:21am 
Mmm, I just checked the script on my end and it seems to work fine for me. Due to the stack trace, the error seems to occur while computing the current solar output. Did you check if the measureSolarPanelName config value is set correctly?
Commander Rotal 2 Feb, 2020 @ 9:53am 
Question, old chap; a while ago the script randomly stopped working both when i try to set it up anew and when i just paste in older buildings i KNOW for a fact should work as they are. Any chance you could take a look at this error message?

Caught exception during execution of script:Object reference not set to an instance of an object.
at Program.getSolarPower()
at Program.Main(String argument)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.<>c__DisplayClass46_0.<ExecuteCode>b__0(IMyGridProgram program)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RunSandboxedProgramAction(Action'1action, String&Response)
roughnecks 19 Nov, 2019 @ 9:51am 
OK, got it working so far, will have to wait for the night and check if it's still going.
Thanks for the script :)
roughnecks 19 Nov, 2019 @ 9:36am 
Oh, there's a timer block, apparently. Will give it a go soon.
roughnecks 19 Nov, 2019 @ 9:24am 
Hello, I loaded the script, left all the settings alone, since they looked fine to me and run the script but my lights still stay on during the day.

Also, how do I setup a timer? I'm really new to SE. Thanks
Commander Rotal 22 Jun, 2019 @ 5:25am 
Oh, it's a delight. Pun intended.
ThatsEli  [author] 22 Jun, 2019 @ 5:20am 
No problem :D I hope you have fun with the script!
Commander Rotal 20 Jun, 2019 @ 8:05am 
Well, weirdly enough NOW it works.

Here's what it threw me last time i played a couple hours earlier without modifying the previously working grid in that world:

https://media.discordapp.net/attachments/125024865232093184/591171534362640424/keeen.png

Now it's working. I had to rename some Spotlights on the second grid, that was my bad, but the original just started working again without changes. Maybe something to do with the hotfix, i dunno. Sorry to take your time :/
ThatsEli  [author] 20 Jun, 2019 @ 7:07am 
No problem :) Mmm, it works for me atm. Does it throw an error? If so, could you send it to me? Maybe there is an special case with your station/ship :)
Commander Rotal 20 Jun, 2019 @ 12:42am 
Sorry to bother you but Keen fiddled around with scripts aaaaaand it doesn't work anymore again -.-'
ThatsEli  [author] 17 Jun, 2019 @ 10:53am 
Ups, i think i messed something up, sorry :D
Commander Rotal 16 Jun, 2019 @ 1:11pm 
Oh! Ah, thank you :) Although i'm neither swiz nor do i live there XD
ThatsEli  [author] 16 Jun, 2019 @ 6:12am 
@Commander Rotal It should be fixed now. This script is/was really old and i fixed a few other bugs with this update. Have fun with it! Und Grüße an die Schweiz ;)
Commander Rotal 15 Jun, 2019 @ 9:35am 
Hey, i was just linked this script because it's EXACTLY what i was looking for. Sadly it doesn't seem to work properly anymore; any chance you would take a quick look at it again?
Dillernissen 7 Feb, 2017 @ 8:08am 
:D
ThatsEli  [author] 7 Feb, 2017 @ 7:35am 
@Drillenissen Thank you! Have fun with it!
Dillernissen 7 Feb, 2017 @ 6:57am 
nice script i mixed it with a nother solar script making it facing the sun... PERFECT:steamhappy:
Kalina Fairhaven 17 Jan, 2017 @ 10:12am 
I'm also getting the "Caught error in execution of script:"index was out of range.Must be non-negative and less than the size of the collection.Parameter name: index"" error whenever I execute the script.
ThatsEli  [author] 8 Jan, 2017 @ 2:44am 
@Darth Aphotic There is a bad guide in the script (http://pastebin.com/QjJkH5Sg) , you can enable a Prefix for the Blocks, by default "[NL]", or you can disable the prefix(Every light will be triggered). Eg. You enable the prefix and add teh prefix to outer lights. There is a script to rename block in groups, see my awnser to @PrairForMercy below. I hope i could help, if you have any questions, please ask them :)
Korvatus Klok 7 Jan, 2017 @ 8:50pm 
Do you have a set up guide somewhere? I just tried to use it in a pre-existing base, and I tend to rename all my lights and group them acording to their locations.
Barrio505 16 Dec, 2016 @ 11:06am 
also get:Object reference not set to an instance of an object.
Barrio505 16 Dec, 2016 @ 11:05am 
Could I get a some instructions here, seems to not be working and I am not sure if the prefix is meant for the solar panels or the lights themselves, either way I am getting an error:Caught error in execution of script:"index was out of range.Must be non-negative and less than the size of the collection.Parameter name: index"
ThatsEli  [author] 6 Sep, 2016 @ 9:30am 
@PrairForMercy :) If you have any other suggestions please message me!
PrairForMercy 6 Sep, 2016 @ 9:27am 
@thatseli prefix is even better :)
ThatsEli  [author] 6 Sep, 2016 @ 5:03am 
@Nathan Thank you!
Nathan 6 Sep, 2016 @ 5:01am 
Nice! Like the idea:) I have no sun rotation in my world currently, but it should be useful on the capital ship. Thanks a lot!
ThatsEli  [author] 6 Sep, 2016 @ 4:43am 
@Giftzwerg-TM- Fixed both the bugs :) Thank you!

@PrairForMercy Had some problems with groups, but you can use now prefix, and with this script( LINK ). You can set the prefix for a group. Here is a example from me : Create a group: "Rename to [NL]Lights" and add all the lights you wan't to use to this group. Now run the script and you got it :) I hope I could help!
ThatsEli  [author] 5 Sep, 2016 @ 7:21am 
@Giftzwerg-TM- Yeah, you are right, I will impelement/fix it :) Thank you!
Giftzwerg-TM- 5 Sep, 2016 @ 5:19am 
Hmm. If you fix one problem there is a new one. :) If you truncate "W instead of "kW" in the time when power is between 0-999 W you get wronge return values, eg 815 instead of 0.815 -> int 1
Giftzwerg-TM- 5 Sep, 2016 @ 5:02am 
Nice script. Thank you. I think there is a small error in the getSolarPower function. You check for "kW" at night time but the string just contains "0 W" not "0 kW" so it don't replace the kW and get an error on the following int conversion.

My quick and dirty fix as a Space Engineer is:

var final = output.Replace(" kW", "");
final = output.Replace(" W", "");

Maybe not nice but it worked for me :)

Greetings
Mike
ThatsEli  [author] 2 Sep, 2016 @ 7:11am 
@PrairForMercy Will add in in ~ 2 days, hve/had not many time and birthday :)
PrairForMercy 31 Aug, 2016 @ 12:34pm 
Cool thanks
ThatsEli  [author] 31 Aug, 2016 @ 7:20am 
@PrairForMercy I will implement it!
PrairForMercy 30 Aug, 2016 @ 12:31pm 
Could you make it work with a group instead of all lights on grid?
ThatsEli  [author] 30 Aug, 2016 @ 4:02am 
@Talbone Added it!
Talbone 29 Aug, 2016 @ 10:48pm 
compatible with spotlights?
ThatsEli  [author] 28 Aug, 2016 @ 10:19am 
@qwertybattle you could turn of the timer, but I will add that function :) Thank you for your feedback!
AzureAssaulter 28 Aug, 2016 @ 10:14am 
make sure there is an override so that you can turn them all off during combat or to save power