Stationeers

Stationeers

View Stats:
IC10 Grow Light Question
https://steamcommunity.com/sharedfiles/filedetails/?id=3592922226

Learning the code slowly. Trying to figure out the discrepancy between defining the string assigned to d0 and making sure that d0 is assigned to the grow light ash. I tried the numerical value and the "StructureGrowLight" but cant seem to get it correct. Thanks in advance.
< >
Showing 1-15 of 26 comments
I have the current working code as

alias GrowLight d0 # Set all grow lights to d0

define GrowLight -1758710260 #Load Grow Light's hash into the int

start:
sb GrowLight On 0
sleep 400
sb GrowLight On 1
sleep 800
j start

What I would like to be able to do is for the code to automatically import the hash of the device connected at d0.
d0 is device pin 0 on the housing, it's a single device you assign with the screwdriver. You can't alias 'all' growlights via a single device pin.
As such the alias and the define are doing two different things to the name 'GrowLight' and may conflict with one another.

I think the way to do what you want is:

alias device d0 # get a reference to the single device connected to d0
alias deviceType r0 # create a register to use as a storage for the hash of the connected device type

l deviceType device PrefabHash # copy the prefab hash from the connected device into deviceType. for growlights this is -1758710260

sb deviceType On 1 # batch turn on everything of the device type defined by the prefab hash
#etc

This way, if you plug a growlight into d0, it'll turn on all growlights on the network. If you plug in a light it'll turn on all lights of that type, if you plug in a printer it'll turn on all printers of that type, etc.
If you just want d0's item hash, I think this'll do:
l r0 d0 PrefabHash #Sets 'r0' to the PrefabHash of whatever is on d0. alias AllLights r0 # Let's you reference the Prefab Hash on r0 as AllLights.
d0-5 are all single devices you use a screwdriver to set on the circuit housing.

r0-16 are your registers you can use to store variables and stuff freely.
...
That said, this looks like a simple on/off for growlights, so you could skip variables, hashes, aliases & device pins altogether like this:
Start: sb -1758710260 On 0 sleep 400 sb -1758710260 On 1 sleep 800 j Start
The number is universal for all growlights, so it'll affect them all if they're connected to the cable.

's' is for saving to a single device.
'sb' is for saving to all devices of a type by ItemHash.
'sbn' is for saving all devices of a type by ItemHash with a specific label.
If you do it the 'load device hash based on pin 0' method then aliasing the pin does provide a small benefit in that hovering over the pin will display the pin's alias to give you an idea of what's supposed to go there.

But yeah, you don't want both an 'alias' (nickname for device or register) and "define" (nickname for a specific number) to have the same name.

So in the [s]original[/s] second code you posted you would get rid of the entire 'alias' line so you're just left with defining the grow light hash as GrowLight. You were very very close to having something that worked actually. (that is, something that worked only for grow lights and doesn't need to read any devices on pins)

By the way when writing out code here you can use BBCode like this:
[code]paste your code in between these code tags[/code]

EDIT: Sorry, I just saw the part in your second post about wanting to load the hash from the pin. Just go with what Daggoth said. Kyle's is a super simplified version of what I thought you wanted.
Originally posted by Zulban:
Just go with what Daggoth said. Kyle's is a super simplified version of what I thought you wanted.
I'm somewhat new to this so apologies if it's wrong, but aren't our lines doing the same thing?

We're both saving the d0's hash on a register & giving it an alias, just theirs has an extra alias for the d0 pin itself, I think.

(I'll clean it up to be more clear in an edit, though.)
I'm obviously staying up too late because it seems I can't read, uhg. Yes, you are right, I missed the first part of your post as well and was just looking at the second code block. Just ignore what I've said.
This implementation does not require screws, affects all grow lights on this network, and allows for more code (other topics) to be added because it doesn't block via sleep commands.

define GROLI HASH("StructureGrowLight") alias GROLIon r15 alias GROLIcounter r14 start: yield sub GROLIcounter GROLIcounter 1 # Count down in game ticks (0.5s) bgtz GROLIcounter GroliDone # Not at zero? Then skip logic. seqz GROLIon GROLIon # Flip on/off. select GROLIcounter GROLIon 1500 900 # 1500=12.5m 900=7.5m 1800=15m 600=5m GroliDone: sb GROLI On GROLIon # Set grow light on/off, whatever register currently says. s db Setting GROLIcounter # Maybe show counter as Housing tooltip value. j start
So "sbn" is the code for grow lights for different plants? When you have some for tomato (named: Light.Tomato) and some for special plants (named: Light.Special).
Originally posted by Graf Schokola:
So "sbn" is the code for grow lights for different plants? When you have some for tomato (named: Light.Tomato) and some for special plants (named: Light.Special).

Yep. But the current timing (12.5/7.5 minutes via 1500/900) is suitable for potatoes, wheat, soy beans, so no separation needed. If I had only potatoes, I would use 16.6/3.3 via 2000/400, for more yield.
Originally posted by God, owner of the Universe:
Originally posted by Graf Schokola:
So "sbn" is the code for grow lights for different plants? When you have some for tomato (named: Light.Tomato) and some for special plants (named: Light.Special).

Yep. But the current timing (12.5/7.5 minutes via 1500/900) is suitable for potatoes, wheat, soy beans, so no separation needed. If I had only potatoes, I would use 16.6/3.3 via 2000/400, for more yield.
Thank you.
curious as to why you chose to load the prefab hash over d0 rather than just look it up and paste it in?

it's not an issue in super simple scripts like this, but depending how deep you get into the scripting six device pins already won't be enough for all your devices even without accounting for pins to load prefab hashes.
"alias" is used to assign a "name" to a device or a register. It depends a little, but "usuallly" this means the 6 devices (d0 --> d5) and the 16 registers (r0 --> r15)

Note, there are special cases like mounting a chip in a a machine where less than 6 devices available and there a a couple of special devices (db) and registers (ra = r15)

"define" is used to assign a "name" to a NUMBER. Note, you can redefine names, so defines are not neccessarily constant. NUMBERS are generally Hashes, but can be other values as well, including up to 6 character "strings" in the current version of stationeers.
Originally posted by Duke Leto:
(ra = r15)
ra != r15
I had some complicated code running everything on the grow lights timer on my last base, so I decided to simplify that part. Jumping in and out of loops was causing my timing to drift a bit (using counters calibrated to minutes). For this one I devoted a single IC10 to light timing:

Start: yield sbn HASH("StructureLogicMemory") HASH("growlight-mem") Setting 1 sleep 900 sbn HASH("StructureLogicMemory") HASH("growlight-mem") Setting 0 sleep 300 j Start

And then stuffed the grow light control on my main IC10:

... lbn r0 HASH("StructureLogicMemory") HASH("growlight-mem") Setting 1 sb HASH("StructureGrowLight") On r0 ...

Sure is easier, but I don't think it saves anything at the moment. The "sleep" script could be modified to send other timed signals to other devices later if I wish. I'd just have to grid out the new schedule. Another advantage is that I could easily insert an override in the main loop.
I turn my grow lights on using the vertical angle from a daylight sensor. Lights are on when the sun is above -120 (or something close to that) for about 6.5 minutes of darkness.

That gives me a nice long grow period that can be used in sync with real sunlight and gives me plenty of room to use the same chip to handle base cooling and weather monitoring.
< >
Showing 1-15 of 26 comments
Per page: 1530 50

Date Posted: Oct 24, 2025 @ 3:42pm
Posts: 26