stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 94

Day 94 of 365 · Advanced · Month 4: Network in detail

Count, Minimum and Maximum on purpose

Count counts devices – but without regard to the name. Minimum finds the weakest link. With Sum over PrefabHash you still count by name.

Lesson 14 min Week 14

What you learn today

  • Count devices
  • Count ignores the name
  • Find the weakest link

Three living rooms, a gas sensor called “Wohnen” in each. You want to know: how many sensors are running at all? Where is the air worst? That is what Count, Minimum and Maximum are for, with a few quirks.

Count counts devices

Count returns the number of devices, not a value. The chip still checks the LogicType: if a matching device cannot read it, you get IncorrectLogicType. Every device can read PrefabHash.

lb count SENSOR PrefabHash Count    # all gas sensors on the network

Count ignores the name

In the game code Count counts all devices with the matching prefab hash. It does not look at the name, not even with lbn:

lbn count SENSOR HASH("Wohnen") PrefabHash Count   # counts ALL gas sensors

If a sensor “Aussen” hangs on the same network, it counts too. For a count by name there is a trick: every device reports its own PrefabHash. The sum over all devices with this name, divided by the hash, is their number:

lbn total SENSOR HASH("Wohnen") PrefabHash Sum
div count total SENSOR              # only the sensors "Wohnen"

Sum respects the name. Without a match you get 0 divided by the hash, so 0. That case is right too.

Minimum finds the smallest value, Maximum the largest. For the air this means: the room with the least oxygen decides on the alarm, not the average. An average of 21 %, 21 % and 15 % looks harmless at 19 %. The minimum shows the 15 %.

lbn o2 SENSOR HASH("Wohnen") RatioOxygen Minimum
Warning

Minimum returns 0 when no device matches, Maximum returns −infinity. An O₂ minimum of 0 triggers your alarm, which is even right here. With the maximum it goes wrong, and the next lesson deals with that.

Tip

Compare the counted number with the number you built. If a sensor is missing you notice at once, even if the others report good values.

Diagram

Three readings, five batch modes Sensor “Raum” 300 K Sensor “Raum” 310 K Sensor “Raum” 250 K lbn Average 286.67 Sum 860 Minimum 250 Maximum 310 Count 3 Sum on temperatures: 860 K – the heater thinks there is a fire.
Count only looks at the type, Sum and Minimum at the name as well. The sum of the PrefabHashes divided by the hash is the count by name.

Exercise

Task

Three gas sensors are called “Wohnen”, a fourth one is called “Aussen” and hangs on the same network.

  • LED “O2min”: the lowest oxygen ratio of the sensors “Wohnen” in percent
  • LED “Sensoren”: the number of sensors “Wohnen” (the outside sensor does not count)
  • flashing light “Luftalarm”: on below 19 % oxygen or if fewer than 3 sensors “Wohnen” are present

Hints

Hint 1

For the weakest link use Minimum instead of Average.

Hint 2

Count also counts “Aussen”. Use lbn … PrefabHash Sum and divide by SENSOR.

Hint 3

Alarm: slt for the oxygen, slt for the count, then or.

Quiz

4 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed the simulator exercise
  • Passed the quiz with at least 60 %

Without an account progress is saved in this browser only.

Report a mistake in this lesson

Please sign in to report. Sign in

Esc
↑ ↓ selectEnter open/ opens search anywhere