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

Day 31 of 365 · Beginner · Month 2: Order and data network

Constants and namespaces

pi, nan, pinf, ninf, rgas and names like Color.Red or GasType.Oxygen: which names the chip knows and where they apply.

Lesson 11 min Week 5

What you learn today

  • Pi, nan, pinf, ninf and rgas
  • Color., GasType., LogicType. at number positions
  • Bare names only in their place

How many moles are in your tank? You need the gas constant for that. Which number is the colour orange? You do not have to know it by heart. The chip knows built-in constants and whole namespaces.

Built-in constants

NameValuefor
pi3.14159…circles, angles
tau6.28318…a full circle in radians
deg2rad, rad2degdegrees ↔ radianssun angles
rgas8.31446… J/(mol·K)gas amounts
pinf, ninfplus and minus infinitystarting point for minimum and maximum searches
nan“not a number”error value
epsilonsmallest positive numberrarely useful

rgas: moles from pressure

With pressure in kPa and volume in litres you compute moles directly: n = p · V / (R · T). One kPa times one litre is exactly one joule, the units fit.

define VOLUME 6000       # litres, small tank
alias mol r2
mul mol r0 VOLUME        # r0 = pressure in kPa
div mol mol rgas
div mol mol r1           # r1 = temperature in K

Prefixed names

Wherever a number may stand, prefixed names work as well:

NamespaceExamples
Color.Color.Green = 2, Color.Red = 4
DisplayMode.DisplayMode.Celsius = 4, DisplayMode.Mol = 13
GasType.GasType.Oxygen = 1, GasType.CarbonDioxide = 4
LogicType.LogicType.Temperature = 6
Vent., Sound., PowerMode. …come in the device lessons

The prefix is relaxed about upper and lower case, the name behind it is not: Color.Red works, Color.red does not. A define may carry such a name too: define COLOUR_OK Color.Green.

Bare names only in their place

The chip only understands Temperature without a prefix where a LogicType is expected – that is, in l r0 d0 Temperature. At a number position the same bare name is an error:

move r0 Temperature             # error
move r0 LogicType.Temperature   # 6

The same goes for batch modes like Average: bare only at the very end of lbn.

Warning

nan directly at a value position, such as select r0 r1 nan r2, raises an error in the game. The workaround: define NAN nan and then use NAN.

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
Constants and prefixed names belong in the settings section – that keeps the body free of raw numbers.

Exercise

Task

A mole calculator for the small tank (6000 litres): a pipe analyzer on the tank is attached to d0, an LED display to d1.

  • The display shows the gas amount n = p · V / (R · T) in moles. Use the constant rgas.
  • Display in mode DisplayMode.Mol, colour Color.Orange – with names, not numbers.
  • Workshop style: define, alias, sections.

Hints

Hint 1

Read pressure and temperature from the analyzer with l.

Hint 2

mul mol press VOLUME, then two div: by rgas and by the temperature.

Hint 3

Mode and colour: s display Mode DisplayMode.Mol, s display Color Color.Orange.

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

Esc
↑ ↓ selectEnter open/ opens search anywhere