What you learn today
- Read autolathe and printers
- Progress and completion
- Resupply raw materials
Twenty iron sheets for the new room – and every time walk to the lathe, look for the recipe, press the button. A chip can preselect the recipe, show the progress and report when material is missing.
What the fabricators have in common
The autolathe (StructureAutolathe), electronics printer, tool manufactory and hydraulic pipe bender work the same way:
| LogicType | Meaning |
|---|---|
RecipeHash | read: what is selected now; write: choose the recipe by prefab hash |
Activate | 1 = fabricating right now; writing 1 starts |
CompletionRatio | progress of the running piece, 0 to 1 |
Reagents | loaded material in total |
ExportCount | how many items have been output |
Open | returns loaded material as ingots |
Slot 1 is the output. If something lies there, a piece is done and waiting to be collected.
Choosing the recipe
sbn LATHE HASH("Drehbank") RecipeHash PRODUCT
PRODUCT is the prefab hash of what should come out, for example HASH("ItemIronSheets"). According to the recipe data an iron sheet needs 1 iron and one second, an iron frame 4 iron and four seconds. Writing the value every tick does no harm: the fabricator only switches when the hash really changes.
Activate: only at the right moment
This is where the most important trap lies. Activate 1 starts a job, and while it runs Activate stays at 1. If the chip writes a 0 in between, it cancels the job. So never pass the button value to the fabricator every tick, but write a 1 only on a press:
lbn tmp BUTTON HASH("Start") Activate Average
sgtz tmp tmp
beqz tmp start
sbn LATHE HASH("Drehbank") Activate 1
sgtz makes sure a missing button (NaN) does not count as a press.
Resupplying raw materials
If Reagents drops below a limit, it will soon be over. A light “Nachschub” calls for ingots in time. Which ingot exactly is missing you have known since yesterday: lr … Required and rmap.
Open 1 does not mean “door open” on fabricators: they then return their loaded material as ingots. Whoever sets Open by accident empties the lathe.
Exercise
Task
The autolathe is named “Drehbank”. Choose the recipe ItemIronSheets every tick. Show CompletionRatio on “Fortschritt” (mode DisplayMode.Percent, −1 without lathe). The light “Fertig” is on when slot 1 is occupied, the light “Nachschub” when Reagents is below 10. Only a press on the button “Start” writes Activate 1 – otherwise the chip never writes Activate.
Hints
Hint 1
Recipe: sbn … RecipeHash PRODUCT.
Hint 2
Done: lbns tmp LATHE HASH("Drehbank") 1 Occupied Average, then sgtz.
Hint 3
Start at the very end: read the button, sgtz, beqz tmp start, only then Activate 1.
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