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

Day 227 of 365 · Pro · Month 8: Production

Displaying production

Count and display piece counts in storage, set a target amount by dial and show the progress in percent with colour.

Lesson 16 min Week 33

What you learn today

  • Show quantities
  • Target amounts
  • Progress in percent

“How many frames do we have?” – “Enough?” – “How many are still missing?” Three questions, three displays. Whoever expands a station wants to see that at a glance without opening the locker.

Showing piece counts

The frames lie in the locker “Rahmenlager”. You know the counting loop over all 30 slots: lbns with the slot index in a register, Sum for real piece counts. If only one kind lies in the locker, you need no hash comparison.

Target amounts

A dial (StructureLogicDial) “Ziel” sets the target amount. A player turns it to 40 when 40 frames are needed. From that the chip calculates what is still missing – never less than 0:

sub tmp target stock
max tmp tmp 0

Progress in percent

The share is stock divided by target. The display in mode DisplayMode.Percent wants the share from 0 to 1 – and more than 100 % looks confusing, so min caps it at 1:

div share stock target
min share share 1

The colour tells the rest: yellow while the target is not reached, green from 100 %, red when the target is invalid.

Warning

A target of 0 gives a division by 0. A missing dial gives NaN. sgtz ok target catches both: only a target above 0 is valid. Otherwise “Rest” shows −1, the progress 0 and the colour red.

Several displays, one tick

Three displays with different units from the same two numbers: stock as a number, remainder as a number, progress in percent. The chip calculates once and distributes – just like the power dashboard.

Exercise

Task

Count the pieces in all 30 slots of the locker “Rahmenlager” and show them on “Bestand”. The dial “Ziel” sets the target amount. “Rest” shows target minus stock, never below 0. “Fortschritt” shows stock divided by target in percent mode, at most 100 %, yellow before the target, green from the target. If the target is not above 0 or the dial is missing: remainder −1, progress 0, red.

Hints

Hint 1

Counting loop with lbns … i Quantity Sum.

Hint 2

Validity: sgtz ok target – catches 0 and NaN at once.

Hint 3

Progress: div, min … 1, select … ok … 0; colour in two select.

Quiz

3 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