Six pins fill up fast. And when you rebuild a device, you have to set the pin again. Better: address devices through the data network.
Every device has a type hash
Every device type has an internal name, the prefab, for example StructureGasSensor. The game turns it into a number, the hash. You do not need to know the number – HASH("…") computes it when the code loads:
define SENSOR HASH("StructureGasSensor") # Gas Sensor
You find prefab names in the prefab search of the IC10 coder.
You choose the names
With the labeller you give devices a name in game, such as “Storage”. HASH("Storage") turns that into a number as well.
lbn and sbn
lbn temp SENSOR HASH("Storage") Temperature Average
sbn HEATER HASH("StorageHeat") On 1
lbnreads the value from all devices of that type with that name and combines it.Averagetakes the mean – more about that in the next lesson.sbnwrites the value into all matching devices at once. Three heaters named “StorageHeat”? One line switches all three.
Use plain ASCII in HASH("…"). The chip only stores ASCII; with special characters the hash no longer matches the device name.
Without a name there are lb and sb: they hit every device of a type on the network. Handy for “all lights off”.
Diagram
Exercise
Task
The data network holds two gas sensors (“Lager” and “Werkstatt”) and three wall heaters – two named “Lagerheizung”, one “Werkstattheizung”.
When the Lager is colder than 5 °C (278.15 K), both Lagerheizung heaters should run, otherwise off. The Werkstattheizung stays untouched.
Use lbn/sbn with HASH("…") – no pins d0–d5. Prefabs: StructureGasSensor, StructureWallHeater.
Hints
Hint 1
Read: lbn temp SENSOR HASH("Lager") Temperature Average.
Hint 2
Compare as in the select lesson: slt on temp LIMIT.
Hint 3
Write into both heaters at once: sbn HEATER HASH("Lagerheizung") On on.