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

Day 323 of 365 · Expert · Month 11: Optimisation and debugging

The style guide

The workshop style guide: define and alias consistently, sections, comments without special characters – and for every rule the reason behind it.

Lesson 18 min Week 47

What you learn today

  • define and alias consistently
  • Sections
  • Comments

You have known the workshop rules since month 1. Today they are all together in one place, each with its reason. Whoever knows the reason also knows when a rule exceptionally does not fit.

The rules

RuleReason
define for every prefab hash and every constant, with a commentnumbers in the body have no name, one change in one place is enough
alias for every register, block after the definestRoom instead of r3 – you still know later what is in it
devices via lbn/sbn with HASH("Name")no 6-pin limit, devices are found by their name in the game
batch mode Averagetwo sensors with the same name must not be added up
sections # --- 1. Measure ---the flow is visible at a glance
only labels as jump targetsline numbers shift with every new line
yield in every main loopone pass per tick, fresh readings
endless loopotherwise the chip stops after one pass
Kelvin literal with Celsius in the commentthe chip calculates in Kelvin, you think in Celsius
no deprecated instructionsl and s can do everything ld and sd could

Comments and names

The workshop writes its comments in German, but without special characters: the checker in the IC10 coder warns that the game turns umlauts in comments into “?”. So “Kuehlung” instead of “Kühlung”. For device names in HASH("…") this applies anyway: the hash is computed from the characters, and an umlaut no longer matches the name on the device.

What it looks like

# --- Air watch lab ---
define SENSOR HASH("StructureGasSensor") # gas sensor
define GRENZE 0.02 # 2 % CO2, alarm above
alias co2 r0
alias alarm r1
start:
yield
# --- 1. Measure ---
lbn co2 SENSOR HASH("Labor") RatioCarbonDioxide Average
# --- 2. Alarm ---
sgt alarm co2 GRENZE
j start
Tip

Style costs characters. In a long script the comments are usually the reason why the 4096 characters get tight. Then shorten the comments, not the defines – a short comment is better than a nameless number.

Diagram

Program layout in the proven style # --- Heat warning --- define LIMIT 303.15 # 30 C define SENSOR HASH("…") alias temp r0 alias hot r1 start: yield … j start 1 · define everything tunable 2 · alias names for registers 3 · main loop with yield, endless
The layout every workshop script has: header, defines, aliases, loop with yield and numbered sections.

Exercise

Task

The starter code is a working air watch from the early days: pins, raw numbers, a jump to line 0, no NaN guard. Rebuild it according to the guide. Sensor “Labor”, display “Labor_CO2” (CO₂ in percent with one decimal, -1 without sensor, colour green or red on alarm), flashing light “Labor_Alarm” (on above 2 % CO₂ and with a missing sensor). Every number gets a define.

Hints

Hint 1

Pins out: lbn/sbn with the three names and defines for the three prefabs.

Hint 2

0.02, 1000, 10 and -1 also get a define, plus Color.Green and Color.Red.

Hint 3

j 0 becomes a label, and snanz plus select catch the missing sensor.

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