What you learn today
- Read a hydroponics tray
- Growth and Mature
- Report ripeness
Tomatoes take their time. Instead of walking through the greenhouse every few minutes, a lamp should light up as soon as something is ripe.
The right tray
There are two hydroponics trays, and only one of them talks to the chip:
| Prefab | Name in game | Data port |
|---|---|---|
StructureHydroponicsTray | Hydroponics Tray | no |
StructureHydroponicsTrayData | Hydroponics Device | yes |
The simple tray is a pure pipe piece without logic. For the chip you need the Hydroponics Device. According to the Stationpedia these devices cannot be placed right next to each other like the simple trays, so plan a little more space.
With the simple tray lbs finds no device. Depending on the batch mode you get NaN, 0 or −infinity, and you look for the bug in the code instead of in the tray.
Slot 0: the plant
Slot 0 is the plant, slot 1 the fertiliser. Among other things the plant reports:
| LogicSlotType | Value |
|---|---|
Growth | growth stage, a whole number (0, 1, 2 …) |
Mature | 1 = ripe, 0 = not yet |
MaturityRatio | way to ripeness from 0 to 1 |
Health | health from 0 to 1 |
Without a plant all four report −1. That becomes important in a moment.
lbs ripe TRAY 0 Mature Maximum # 1 as soon as a plant is ripe
lbs progress TRAY 0 MaturityRatio Maximum
Growth is not a percentage but the number of the stage. How many stages a plant has depends on the variety. For a “how far?” display MaturityRatio is the better choice.
Maximum for “any”
With Maximum you ask: is any plant ripe? A ripe plant returns 1, so the maximum is 1 as well. Empty trays return −1 and do no harm.
Sum over Mature does not count the ripe plants. An empty tray subtracts a ripe plant again with its −1: 1 + 0 + (−1) = 0.
For a clean lamp you turn the result into 0 or 1 with sgtz. That also covers the case “no tray on the network at all”: Maximum returns −infinity there, and sgtz turns it into 0.
sgtz ripe ripe
sbn LAMP HASH("Ernte") On ripe
For the percentage display multiply MaturityRatio by 100 and add max progress progress 0. That way the display shows 0 instead of −100 or −infinity when all trays are empty.
Diagram
Exercise
Task
Three hydroponics devices stand on the data network of the greenhouse.
- The wall light “Ernte” lights up as soon as one plant is ripe.
- The LED display “Reife” shows the
MaturityRatioof the most advanced plant in percent (0 to 100). - If all trays are empty or removed: lamp off, display 0.
Hints
Hint 1
lbs ripe TRAY 0 Mature Maximum – slot 0 is the plant.
Hint 2
sgtz turns 1 / 0 / −1 / −infinity into a clean 0 or 1.
Hint 3
For the display read MaturityRatio with Maximum, times 100, then max … 0.
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