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

Day 73 of 365 · Beginner · Month 3: First systems

The battery charger

Through ChargeRatio the battery charger tells you how full every cell is. A lamp reports “all full” – but only if batteries are really inside.

Lesson 12 min Week 11

What you learn today

  • Read batteries in a slot
  • ChargeRatio
  • “full” indicator

Battery cells for tools and wall lights end up in the battery charger. The large charger (StructureBatteryCharger) has 5 slots, the small one (StructureBatteryChargerSmall) 2. Which battery is full, which still needs time? The chip tells you before you walk over.

What a battery in a slot reports

LogicSlotTypeMeaning
Occupiedis a battery in the slot?
Chargestored energy in J
ChargeRatiocharge level from 0 to 1

ChargeRatio is the value you work with: 0.5 means half full, 1 means full. For percent multiply by 100.

lbs ratio CHARGER 0 ChargeRatio Average  # slot 0
mul percent ratio 100

With one charger on the network Average returns exactly its value – and NaN if the charger is missing. You already know the NaN guard for that.

Warning

An empty slot reports ChargeRatio 0, just like an empty battery. So always check Occupied first. Otherwise your chip reports “battery empty” although there is simply none inside.

Note

How fast a tool empties its cell when building and deconstructing does not depend on the tool: every finished build or deconstruction step costs a flat 1,000 J. Loose cells also lose up to 50 J per tick in cold below 0 °C.

“All full” across all slots

A slot is fine if it is empty or its battery is full. All slots together are fine if every single one is fine. That is an and across the loop:

move allFull 1
move i 0
slot:
lbs present CHARGER i Occupied Average
lbs ratio CHARGER i ChargeRatio Average
sge ok ratio FULL       # full?
seqz empty present      # or empty?
or ok ok empty
and allFull allFull ok
add i i 1
blt i SLOTS slot

Use 0.99 as the limit instead of exactly 1. Whether the value reaches exactly 1 in the game depends on the calculation behind it. A threshold keeps you on the safe side.

An empty charger is not “full”

If no battery is inside at all, every slot is “fine” and the lamp would report “full”. Count the batteries as well and require at least one:

add count count present   # inside the loop
sgtz present count        # after the loop
and allFull allFull present

If the charger is missing entirely, count becomes NaN. sgtz then returns 0 and the lamp stays off. For the display you replace NaN with 0 using snan and select.

Tip

According to the Stationpedia the large charger draws 10 W even when it charges nothing. If you need to save power, set On to 0 as soon as everything is full.

Diagram

A locker with numbered slots Locker (d0) Slot 0 Iron ore Occ 1 Qty 5 Slot 1 Copper ore Occ 1 Qty 12 Slot 2 empty Occ 0 Qty 0 Slot 3 empty Occ 0 Qty 0 ls r0 d0 0 Occupied r0 = 1 ls r1 d0 1 Quantity r1 = 12 Slots count from 0. Values in a slot are called LogicSlotTypes.
Five slots, five batteries: every slot reports Occupied and ChargeRatio. An empty slot looks just like an empty battery.

Exercise

Task

A battery charger (StructureBatteryCharger, 5 slots) sits on the network.

  • The wall light “Voll” is on when at least one battery is inside and every battery in the charger has at least 99 %.
  • The LED display “Akkus” shows how many batteries are in the charger.
  • If the charger is missing: lamp off, display 0, no error.

Hints

Hint 1

A slot is fine if ChargeRatio ≥ FULL or Occupied = 0.

Hint 2

Combine all slots with and allFull allFull ok – set allFull to 1 first.

Hint 3

After the loop: replace NaN in count with 0 via snan/select, then sgtz and one more and.

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