What you learn today
- Trays and slots
- Growth, Mature, Health
- Recognise plants
The potatoes in the greenhouse are growing, but you only see whether they are ripe when you walk over. A chip can check that for you – if you built the right tray.
Two trays, only one talks
| Part | Prefab | Data port |
|---|---|---|
| Hydroponics tray | StructureHydroponicsTray | none, it is a piece of pipe |
| Hydroponics device | StructureHydroponicsTrayData | yes |
Both need water through a liquid pipe and light. You can lay the plain tray in long rows, but no chip can look inside. The device has a data port, but you must not place two of them directly next to each other. For everything in these two weeks you need the device.
Two slots
Slot 0 is the plant, slot 1 the fertiliser. All values are read-only. You read them with ls through a pin or on the network with lbns:
| Slot type | means | without a plant |
|---|---|---|
Occupied | 1 if something is in the slot | 0 |
OccupantHash | prefab hash of the plant | 0 |
Growth | growth stage as a whole number | −1 |
MaturityRatio | progress towards ripeness, 0 to 1 | −1 |
Mature | 1 ripe, 0 not yet | −1 |
Health | health, 1 is undamaged | −1 |
Efficiency | how well it grows right now, roughly 0 to 1 | −1 |
define TRAY HASH("StructureHydroponicsTrayData") # hydroponics device
alias ripe r0
lbns ripe TRAY HASH("Beet") 0 Mature Average # 1, 0 or -1
An empty tray returns −1 for Mature, Growth, Health and MaturityRatio, not 0. bnez ripe harvest therefore also jumps for an empty tray. Test for 1 explicitly: seq ripe ripe 1.
Growth stages
Growth counts the stages. According to the game data the potato grows in four stages of 1000 seconds each, stage 5 is ripe. MaturityRatio is the stage divided by the ripe stage – so the value jumps in steps of 0.2 and does not run smoothly. If the plant grows badly, each stage takes longer, but the value stays a stage.
Recognising plants
OccupantHash is the prefab hash of the plant: potatoes are ItemPotato, tomatoes ItemTomato, wheat ItemWheat. With a define and seq you know what is in the tray:
define POTATO HASH("ItemPotato") # potato plant
alias kind r1
lbns kind TRAY HASH("Beet") 0 OccupantHash Average
seq kind kind POTATO # 1 = potato
Name every hydroponics device with the labeller, for example “Beet”. Then lbns reads exactly this tray, no matter how many others hang on the network.
Diagram
Exercise
Task
The hydroponics device “Beet” is on the network. Write a chip that reads slot 0 every tick:
- light “Reif” on when
Matureis exactly 1 - light “Kartoffel” on when a potato (
ItemPotato) is in the tray - display “Wachstum” shows
MaturityRatioin whole percent, −1 for an empty tray or a missing device
Hints
Hint 1
Three lbns on slot 0: Mature, MaturityRatio and OccupantHash.
Hint 2
seq ripe ripe 1 instead of snez – the empty tray returns −1.
Hint 3
For the display: combine snan and sltz with or, then select progress bad -1 progress.
Quiz
5 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