<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://stationeers-wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SemlerPDX</id>
	<title>Stationeers Community Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://stationeers-wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SemlerPDX"/>
	<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/Special:Contributions/SemlerPDX"/>
	<updated>2026-04-05T07:11:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Transformer&amp;diff=25526</id>
		<title>Transformer</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Transformer&amp;diff=25526"/>
		<updated>2026-01-15T20:16:59Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: /* Notes */ clarified details on the 10W draw of transformers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Power]]&lt;br /&gt;
{{Itembox&lt;br /&gt;
 | name        = Kit (Transformer)&lt;br /&gt;
 | image       =  [[File:{{#setmainimage:ItemKitTransformerSmall.png}}]]&lt;br /&gt;
 | stacks      = No&lt;br /&gt;
 | createdwith = [[Electronics Printer]], [[Fabricator]]&lt;br /&gt;
 | cost        = 10x [[Iron]], 1x [[Gold]] , 3x [[Copper]]&lt;br /&gt;
}}&lt;br /&gt;
{{Itembox&lt;br /&gt;
 | name        = Kit Transformer (Large)&lt;br /&gt;
 | image       =  [[File:{{#setmainimage:ItemKitTransformer.png}}]]&lt;br /&gt;
 | stacks      = No&lt;br /&gt;
 | createdwith = [[Electronics Printer]], [[Fabricator]]&lt;br /&gt;
 | cost        = 10x [[Steel]], 5x [[Electrum]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The transformer is used to control the maximum amount of power that will flow on a cable, preventing the cables from overloading on high power draw. &lt;br /&gt;
There are three variants of the transformer:&lt;br /&gt;
&lt;br /&gt;
The Transformer (Small) requires 1x Kit (Transformer) to place and is limited to 5,000 W of output. It can be placed in any orientation on a supporting surface (floor, wall, or ceiling) and is available as Transformer Reversed (Small).&lt;br /&gt;
&lt;br /&gt;
The Transformer (Medium) requires 3x Kit (Transformer) to place and is limited to 25,000 W of output. Similarly, it can be placed on any floor, wall, or ceiling and is available as a Transformer Reversed (Medium).&lt;br /&gt;
&lt;br /&gt;
The Transformer (Large) requires 1x Kit Transformer (Large) to place and is limited to 50,000 W of output. It can only be placed in one orientation, ideally the floor, but it can be stacked above floor level by placing it partway into a frame.&lt;br /&gt;
&lt;br /&gt;
==Usage== &lt;br /&gt;
Given that the transformer can limit power very specifically (with large 100 W increments or small 10 W increments), you can control or stop the output line from drawing more than the transformer gives out. This can be used to control many items that don&#039;t have a changing power usage, such as lights, volume pumps, pipe regulators, active vents, and more. This is similar to the [[Area Power Controller]] but does not have a battery buffer.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
Data will not flow through a transformer, isolating the circuit behind their input. &amp;lt;br&amp;gt;&lt;br /&gt;
The transformers seem to generate a large amount of heat. &amp;lt;!-- someone needs to test the details, i noticed a 71 C temperature in a space where i put a large transformer (17-20 C in the rest of the base) -N --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Transformer will use 10W itself (all sizes). This 10W will come from the input side of the transformer, and will not appear as draw on the output side of the transformer.&lt;br /&gt;
&lt;br /&gt;
===Data Network Properties===&lt;br /&gt;
These are all Data Network properties of this device. This list is not tested at all for the Transformer Small and not complete for Transformer (kit/large variant).&lt;br /&gt;
&lt;br /&gt;
==Data Parameters==&lt;br /&gt;
These are all parameters, that can be written to with a Logic Writer, Batch Writer, or Integrated Circuit (IC10). The outputs are listed in the order a Logic Writer&#039;s &amp;quot;VAR&amp;quot; setting cycles through them.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter Name !! Data Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| On || Boolean || Turns the Transformer on when set to 1. Turns it off when set to 0. &lt;br /&gt;
|-&lt;br /&gt;
| Lock || Boolean || Locks the Transformer when set to 1. Unlocks it when set to 0&lt;br /&gt;
|-&lt;br /&gt;
| Setting || Integer || Sets the Transformer&#039;s power (in Watts) limit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Data Outputs==&lt;br /&gt;
These are all parameters, that can be read with a Logic Reader or a Slot Reader. The outputs are listed in the order a Logic Reader&#039;s &amp;quot;VAR&amp;quot; setting cycles through them. You cannot read ratios in IC2 chip (so far) &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter Name !! Data Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| On|| Boolean|| Returns whether the Transformer is turned on. (0 for no, 1 for yes)  &lt;br /&gt;
|-&lt;br /&gt;
| Maximum || Integer|| Maximum setting of this device. (How high the device can be set, see description for specific numbers.)&lt;br /&gt;
|-&lt;br /&gt;
| Lock || Boolean|| Returns whether the Transformer is locked. (0 for no, 1 for yes) &lt;br /&gt;
|-&lt;br /&gt;
| Error || Boolean|| 1 if device is in error state, otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
| Setting || Integer || Returns the current power limit (in Watts) of the Transformer.&lt;br /&gt;
|-&lt;br /&gt;
| RequiredPower || Integer || Idle operating power quantity. (how much power, in watts, the device itself is using, rather than how much power it is passing through.)&lt;br /&gt;
|-&lt;br /&gt;
| Ratio || Float || Ratio of the current power limit to the maximum power limit of the device&lt;br /&gt;
|-&lt;br /&gt;
| PrefabHash|| Integer || The hash of the device. (Can be found in the Stationpedia.)&lt;br /&gt;
|-&lt;br /&gt;
| Power|| Boolean || Returns 1 if the device is powered and on, otherwise 0.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Transformer&amp;diff=25525</id>
		<title>Transformer</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Transformer&amp;diff=25525"/>
		<updated>2026-01-15T20:14:17Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: /* Notes */ removed incorrect note about heavy cables required on all transformer inputs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Power]]&lt;br /&gt;
{{Itembox&lt;br /&gt;
 | name        = Kit (Transformer)&lt;br /&gt;
 | image       =  [[File:{{#setmainimage:ItemKitTransformerSmall.png}}]]&lt;br /&gt;
 | stacks      = No&lt;br /&gt;
 | createdwith = [[Electronics Printer]], [[Fabricator]]&lt;br /&gt;
 | cost        = 10x [[Iron]], 1x [[Gold]] , 3x [[Copper]]&lt;br /&gt;
}}&lt;br /&gt;
{{Itembox&lt;br /&gt;
 | name        = Kit Transformer (Large)&lt;br /&gt;
 | image       =  [[File:{{#setmainimage:ItemKitTransformer.png}}]]&lt;br /&gt;
 | stacks      = No&lt;br /&gt;
 | createdwith = [[Electronics Printer]], [[Fabricator]]&lt;br /&gt;
 | cost        = 10x [[Steel]], 5x [[Electrum]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The transformer is used to control the maximum amount of power that will flow on a cable, preventing the cables from overloading on high power draw. &lt;br /&gt;
There are three variants of the transformer:&lt;br /&gt;
&lt;br /&gt;
The Transformer (Small) requires 1x Kit (Transformer) to place and is limited to 5,000 W of output. It can be placed in any orientation on a supporting surface (floor, wall, or ceiling) and is available as Transformer Reversed (Small).&lt;br /&gt;
&lt;br /&gt;
The Transformer (Medium) requires 3x Kit (Transformer) to place and is limited to 25,000 W of output. Similarly, it can be placed on any floor, wall, or ceiling and is available as a Transformer Reversed (Medium).&lt;br /&gt;
&lt;br /&gt;
The Transformer (Large) requires 1x Kit Transformer (Large) to place and is limited to 50,000 W of output. It can only be placed in one orientation, ideally the floor, but it can be stacked above floor level by placing it partway into a frame.&lt;br /&gt;
&lt;br /&gt;
==Usage== &lt;br /&gt;
Given that the transformer can limit power very specifically (with large 100 W increments or small 10 W increments), you can control or stop the output line from drawing more than the transformer gives out. This can be used to control many items that don&#039;t have a changing power usage, such as lights, volume pumps, pipe regulators, active vents, and more. This is similar to the [[Area Power Controller]] but does not have a battery buffer.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
Data will not flow through a transformer, isolating the circuit behind their input. &amp;lt;br&amp;gt;&lt;br /&gt;
The transformers seem to generate a large amount of heat. &amp;lt;!-- someone needs to test the details, i noticed a 71 C temperature in a space where i put a large transformer (17-20 C in the rest of the base) -N --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Transformer will use 10W itself (all sizes).&lt;br /&gt;
&lt;br /&gt;
===Data Network Properties===&lt;br /&gt;
These are all Data Network properties of this device. This list is not tested at all for the Transformer Small and not complete for Transformer (kit/large variant).&lt;br /&gt;
&lt;br /&gt;
==Data Parameters==&lt;br /&gt;
These are all parameters, that can be written to with a Logic Writer, Batch Writer, or Integrated Circuit (IC10). The outputs are listed in the order a Logic Writer&#039;s &amp;quot;VAR&amp;quot; setting cycles through them.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter Name !! Data Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| On || Boolean || Turns the Transformer on when set to 1. Turns it off when set to 0. &lt;br /&gt;
|-&lt;br /&gt;
| Lock || Boolean || Locks the Transformer when set to 1. Unlocks it when set to 0&lt;br /&gt;
|-&lt;br /&gt;
| Setting || Integer || Sets the Transformer&#039;s power (in Watts) limit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Data Outputs==&lt;br /&gt;
These are all parameters, that can be read with a Logic Reader or a Slot Reader. The outputs are listed in the order a Logic Reader&#039;s &amp;quot;VAR&amp;quot; setting cycles through them. You cannot read ratios in IC2 chip (so far) &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter Name !! Data Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| On|| Boolean|| Returns whether the Transformer is turned on. (0 for no, 1 for yes)  &lt;br /&gt;
|-&lt;br /&gt;
| Maximum || Integer|| Maximum setting of this device. (How high the device can be set, see description for specific numbers.)&lt;br /&gt;
|-&lt;br /&gt;
| Lock || Boolean|| Returns whether the Transformer is locked. (0 for no, 1 for yes) &lt;br /&gt;
|-&lt;br /&gt;
| Error || Boolean|| 1 if device is in error state, otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
| Setting || Integer || Returns the current power limit (in Watts) of the Transformer.&lt;br /&gt;
|-&lt;br /&gt;
| RequiredPower || Integer || Idle operating power quantity. (how much power, in watts, the device itself is using, rather than how much power it is passing through.)&lt;br /&gt;
|-&lt;br /&gt;
| Ratio || Float || Ratio of the current power limit to the maximum power limit of the device&lt;br /&gt;
|-&lt;br /&gt;
| PrefabHash|| Integer || The hash of the device. (Can be found in the Stationpedia.)&lt;br /&gt;
|-&lt;br /&gt;
| Power|| Boolean || Returns 1 if the device is powered and on, otherwise 0.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=IC10&amp;diff=25524</id>
		<title>IC10</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=IC10&amp;diff=25524"/>
		<updated>2026-01-15T20:08:28Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: /* Stack Memory */ added new poke instruction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:IC10 Programming]]&lt;br /&gt;
=Scripting language for IC10 housings / chips=&lt;br /&gt;
MIPS is [[Stationeers]]&#039; inspiration for the in-game scripting language called IC10. It runs on [[Integrated Circuit (IC10)|IC10 chips]] crafted at the [[Electronics Printer]]. &lt;br /&gt;
&lt;br /&gt;
==Registers==&lt;br /&gt;
Internal registers &#039;&#039;&#039;r?&#039;&#039;&#039;: The IC contains 16 CPU registers, numbered &#039;&#039;&#039;r0&#039;&#039;&#039; to &#039;&#039;&#039;r15&#039;&#039;&#039;. From now on referred to as &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Device registers &#039;&#039;&#039;d? logicType&#039;&#039;&#039;: Device registers are written to and from the IC. A device register is numbered &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039; (select via screw), or &#039;&#039;&#039;db&#039;&#039;&#039; (connected device). From now on referred to as &#039;&#039;&#039;d?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Logic and algorithmic with &#039;&#039;&#039;Internal registers&#039;&#039;&#039; ===&lt;br /&gt;
All calculations are exclusively performed to and from &#039;&#039;&#039;r?&#039;&#039;&#039; registers, or generally more understood as variables in programming. You can use aliases to give convenient names with the &amp;lt;code&amp;gt;alias string r?|d?&amp;lt;/code&amp;gt;command (see below). &lt;br /&gt;
&lt;br /&gt;
Internal registers can be manipulated in various ways. &lt;br /&gt;
* Write constant values &amp;lt;code&amp;gt;move r? (r?|num)&amp;lt;/code&amp;gt;: Example: &amp;lt;code&amp;gt;move r0 2&amp;lt;/code&amp;gt; sets r0 to the number 2.&lt;br /&gt;
* Calculate: Calculations are done to- and from these registers, like &amp;lt;code&amp;gt;add r? a(r?|num) b(r?|num)&amp;lt;/code&amp;gt;. Example: &amp;lt;code&amp;gt;add r1 r0 3&amp;lt;/code&amp;gt; adds 3 to r0, and writes to r1.&lt;br /&gt;
&lt;br /&gt;
Note, for any kind of if statements or loop behaviours, knowing about labels, branching, and jumps is essential knowledge. See below.&lt;br /&gt;
&lt;br /&gt;
=== IO to &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
Acronym &#039;&#039;&#039;d?&#039;&#039;&#039; stands for device, where ? is a number corresponding to the screw device selector on the socket.&lt;br /&gt;
You can also read/write to the device where the IC is planted in using device &#039;&#039;&#039;db&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Generally, there are up to 6 devices which can be set using the screwdriver &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039;. A special device register &#039;&#039;&#039;db&#039;&#039;&#039; is the device wherever the IC is mounted upon. Very convenient for atmospheric devices where no separate IC socket is required.&lt;br /&gt;
&lt;br /&gt;
Note, the IC is completely unaware where d? is actually connected to. So if you get a logicType error, check d? number, or check if the screw has been set on the socket. An alias is only convenient to convey what is expected to be set on the d? screw, it does not actually set or program the screw.&lt;br /&gt;
&lt;br /&gt;
* Read from device (load) &amp;lt;code&amp;gt;l r? d? logicType&amp;lt;/code&amp;gt;: Reads logicType, like Pressure from a [[Sensors|gas sensor]], from device d? to register r?. Values can be read from connected devices and put into the register using the &#039;&#039;&#039;l&#039;&#039;&#039; (load) command. For example, if you want to load the state of a door. &amp;lt;br&amp;gt; Example: &amp;lt;code&amp;gt;l r0 Door Open&amp;lt;/code&amp;gt; reads the &#039;Open&#039; field of an object named &#039;Door&#039;, that would be connected to the IC housing of the chip.&lt;br /&gt;
* Write to a device (set) &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;: Write a value from a register back to a device using the command &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;. For example, if d0 is set to a door using the screwdriver, &amp;lt;code&amp;gt;s d0 Open 0&amp;lt;/code&amp;gt; sets the &#039;Open&#039; status of the d0 (a door) to 0, effectively closing the door.&lt;br /&gt;
&lt;br /&gt;
=== batch IO to - &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
&#039;&#039;&#039;Batch writing&#039;&#039;&#039; needs to be done to a specific &#039;&#039;&#039;deviceHash&#039;&#039;&#039; instead of d?. Is unique per device type, which you can find in the [[Stationpedia]] entries.&lt;br /&gt;
* &amp;lt;code&amp;gt;lb r? deviceHash logicType batchMode&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt;sb deviceHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
Additionally, using the following batch commands, a &#039;&#039;&#039;nameHash&#039;&#039;&#039; can be provided to only modify devices with a certain name.&lt;br /&gt;
* &amp;lt;code&amp;gt;lbn r? deviceHash nameHash logicType batchMode &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sbn deviceHash nameHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All hashes used in the game are CRC-32 checksums computed from the strings they represent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;batchMode&#039;&#039;&#039; is a parameter equal to 0, 1, 2, or 3. These are also defined as the constants &#039;&#039;&#039;Average&#039;&#039;&#039;, &#039;&#039;&#039;Sum&#039;&#039;&#039;, &#039;&#039;&#039;Minimum&#039;&#039;&#039;, and &#039;&#039;&#039;Maximum&#039;&#039;&#039; respectively. The word or number can be used.&lt;br /&gt;
&lt;br /&gt;
Combining one of these functions with the &amp;lt;code&amp;gt;HASH()&amp;lt;/code&amp;gt; function can be advantageous:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbn r0 HASH(&amp;quot;StructureGasSensor&amp;quot;) HASH(&amp;quot;Sensor 1&amp;quot;) Temperature Average&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will load the average temperature of all gas sensors on the network named &amp;quot;Sensor 1&amp;quot; onto register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the batch read (lb/lbn) is done on a network without any matching devices the results will be as specified in the table:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Batch read with no devices&lt;br /&gt;
|-&lt;br /&gt;
! Batch Mode !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Average (0) || nan&lt;br /&gt;
|-&lt;br /&gt;
| Sum (1) || 0&lt;br /&gt;
|-&lt;br /&gt;
| Minimum (2) || 0*&lt;br /&gt;
|-&lt;br /&gt;
| Maximum (3) || ninf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; This apparently used to result in pinf, but in version 0.2.6091.26702 both lb and lbn are returning 0.&lt;br /&gt;
&lt;br /&gt;
pinf and ninf are the IC10 constants for &amp;quot;positive infinity&amp;quot; and &amp;quot;negative infinity&amp;quot; respectively, and work much like other numerical constants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
Here are some examples demonstrating all three operations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 10&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Sets register &#039;&#039;&#039;r0&#039;&#039;&#039; to the value 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Copies the value of register &#039;&#039;&#039;r1&#039;&#039;&#039; to register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;l r0 d0 Temperature&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Reads the Temperature parameter from device &#039;&#039;&#039;d0&#039;&#039;&#039; and places the value in register &#039;&#039;&#039;r0&#039;&#039;&#039;.&lt;br /&gt;
Note: not all devices have a Temperature parameter, check the in-game stationpedia.&lt;br /&gt;
&lt;br /&gt;
To set a device specific value (like &#039;&#039;&#039;On&#039;&#039;&#039;), you can write into this value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;s d0 On r0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Writes the value from register &#039;&#039;&#039;r0&#039;&#039;&#039; out to &#039;&#039;&#039;On&#039;&#039;&#039; parameter of device &#039;&#039;&#039;d0&#039;&#039;&#039;. In this example the device will be turned On, if valve of register r0 equals 1, otherwise (register r0 equals 0) it will turned off. See section [[IC10#Device_Variables|Device Variables]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s recommended to use labels (like: &#039;&#039;someVariable&#039;&#039;) instead of a direct reference to the register. See &#039;&#039;&#039;alias&#039;&#039;&#039; in section [[IC10#Instructions|Instructions]].&lt;br /&gt;
&lt;br /&gt;
=== Special registers ===&lt;br /&gt;
There are two more registers. One called &#039;&#039;&#039;ra&#039;&#039;&#039; (return address) and one called &#039;&#039;&#039;sp&#039;&#039;&#039; (stack pointer). The &#039;&#039;&#039;ra&#039;&#039;&#039; is used by certain jump and branching instructions (those ending with &#039;&#039;&#039;-al&#039;&#039;&#039;) to remember which line in the script it should return to. The &#039;&#039;&#039;sp&#039;&#039;&#039; tracks the next index within the stack (a memory that can store up to 512 values) to be pushed (written) to or popped (read) from. Neither &#039;&#039;&#039;ra&#039;&#039;&#039; nor &#039;&#039;&#039;sp&#039;&#039;&#039; is protected, their values can be changed by instructions like any other register.&lt;br /&gt;
&lt;br /&gt;
==Stack Memory==&lt;br /&gt;
The Stack is a memory that can hold 512 different values. Each IC10 has its own Stack, and some devices (like the Logical Sorter) also have a Stack.&lt;br /&gt;
;push r?: adds the value  &#039;&#039;&#039;r?&#039;&#039;&#039; and increments the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;pop r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039; and decrements the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;peek r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;poke address(r?|num) value(r?|num): Stores the provided value at the provided address in the stack.&lt;br /&gt;
;get r? d? address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;getd r? id(r?|num) address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device id into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;put d? address(r?|num) value(r?|num): adds the value to the stack memory off the provided device at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
;putd id(r?|num) address(r?|num) value(r?|num) : adds the value to the stack memory off the provided device id at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, &#039;&#039;&#039;sp&#039;&#039;&#039; can be both written to and read from any time. When reading (&#039;&#039;&#039;peek&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 1 and 512, inclusive. While writing (&#039;&#039;&#039;push&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 0 and 511, inclusive.&lt;br /&gt;
&lt;br /&gt;
Stack memory is persistent on logic chips. This means that if you have a logic chip and push values to the stack, the code that pushes those values can be removed and the stack will retain those values.&lt;br /&gt;
&lt;br /&gt;
Note that this does not carry over to any other logic chips which receive the program of the original; They will need to have their stack memories programmed individually.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stack Traversing&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Traversing the stack can be done similarly to how an array would be traversed in some other languages:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#this will traverse indices {min value} through {max value}-1&lt;br /&gt;
move sp {min value}&lt;br /&gt;
loop:&lt;br /&gt;
add sp sp 1&lt;br /&gt;
peek r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
blt sp {max value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the pop function&#039;s decrementing to make a more efficient loop:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move sp {max value}&lt;br /&gt;
add sp sp 1&lt;br /&gt;
loop:&lt;br /&gt;
pop r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
bgt sp {min value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments can be placed using a &#039;&#039;&#039;#&#039;&#039;&#039; symbol. All comments are ignored by the game when it reads commands. Below is an example of valid code with two comments.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias MyAlias r0 # Text after the hash tag will be ignored to the end of the line.&lt;br /&gt;
# You can also write comments on their own lines, like this.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Device Ports==&lt;br /&gt;
ICs can interact with up to 6 other devices via d0 - d5, as well as the device it&#039;s attached to via db. To change or set a device, use a screwdriver and adjust the device in the IC housing. You can read or set any of the device&#039;s properties, so it is possible to do things like read the pressure or oxygen content of a room on the same Device port. &lt;br /&gt;
&lt;br /&gt;
Additionally, it&#039;s possible to set other IC housings as devices, allowing you to create programs that run across multiple ICs together. For example, an Gas Mixing IC could check the &#039;&#039;&#039; Setting&#039;&#039;&#039;  field of a Atmosphere Sensor IC and act based on the value of the sensor chip.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;l&#039;&#039;&#039; (load) or &#039;&#039;&#039;s&#039;&#039;&#039; (set) instructions you have to read or set these values to your device. Examples:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#Reads the &#039;Temperature&#039; from an atmosphere sensor&lt;br /&gt;
# at device port &#039;d0&#039; into register &#039;r0&#039;.&lt;br /&gt;
l r0 d0 Temperature&lt;br /&gt;
}} &lt;br /&gt;
{{ICCode|&lt;br /&gt;
# Writes the value of the register &#039;r0&#039; to the&lt;br /&gt;
# device on port &#039;d1&#039; into the variable &#039;Setting&#039;.&lt;br /&gt;
s d1 Setting r0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are used to make it easier to jump between lines in the script. The label will have a numerical value that is the same as its line number. Even though it&#039;s possible to use a labels value for calculations, doing so is a bad idea since any changes to the code can change the line numbers of the labels.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
main: # define a jump mark with label &#039;main&#039;&lt;br /&gt;
j main # jumps back to &#039;main&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
Instead of using a register to store a fixed value, a constant can be made. Using this name will refer to the assigned value. With the help of Constants you can save register places.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# defines a Constant with name &#039;pi&#039;&lt;br /&gt;
# and set its value to 3.14159&lt;br /&gt;
define pi 3.14159&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
You can use these constants like any other variables (see: alias in section [[IC10#Instructions|Instructions]]). Example:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# set the value of register &#039;r0&#039; to the value of constant named &#039;pi&#039;.&lt;br /&gt;
move r0 pi &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Numeric values==&lt;br /&gt;
Registers and constants are usually decimal values using double-precision floating point (confirmed?).&lt;br /&gt;
&lt;br /&gt;
Unlike real CPU architectures, integers are not supported as a distinct type, but double FP can represent integers up to about 54 bits before rounding causes problems (the exact number depending what bit patterns you happen to have).&lt;br /&gt;
&lt;br /&gt;
Numbers can be written in hexadecimal by preceding the value with a $ symbol. Values larger than 54 bits might get corrupted. Hex numbers are typically used for ReferenceId values.&lt;br /&gt;
&lt;br /&gt;
Examples: &lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 12345&lt;br /&gt;
move r1 123.456&lt;br /&gt;
move r2 $E1B2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Indirect referencing==&lt;br /&gt;
This is a way of accessing a register by using another register as a pointer. Adding an additional r in front of the register turns on this behaviour. The value stored in the register being used as the pointer must be between 0 to 15, this will then point to a register from r0 to r15, higher or lower values will cause an error.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 5 # stores the value 5 in r0&lt;br /&gt;
move rr0 10 &lt;br /&gt;
# is now the same as &#039;move r5 10&#039; &lt;br /&gt;
# since r0 has the value 5, rr0 points at the register r5&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Additional r&#039;s can be added to do indirect referencing multiple times in a row.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r1 2&lt;br /&gt;
move r2 3&lt;br /&gt;
move rrr1 4&lt;br /&gt;
# is now the same as &#039;move r3 4&#039;&lt;br /&gt;
# since r1 points at r2 which points at r3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This also works with devices&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 2 # stores the value 2 in r0&lt;br /&gt;
s dr0 On 1 &lt;br /&gt;
# is now the same as &#039;s d2 On 1&#039;&lt;br /&gt;
# r0 has the value 2 so dr0 points at d2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Dynamically changing LogicType when interacting with Device Registers ==&lt;br /&gt;
When the &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; instructions are used to read from or write to a Device Register, the LogicType is the variable that will be interacted with (example: in &amp;lt;code&amp;gt;l r0 myDevice Temperature&amp;lt;/code&amp;gt; the LogicType is the Temperature). In most scripts the LogicType will be hardcoded. But it&#039;s also possible to change the LogicType dynamically. The LogicType is an enum, where each type is identified by a unique integer value. This makes it possible to cycle through them in various ways, either as a list placed on the Stack, or by increasing the LogicType value via addition in each loop.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#loop through a list of LogicTypes&lt;br /&gt;
push LogicType.RatioOxygen&lt;br /&gt;
push LogicType.RatioVolatiles&lt;br /&gt;
push LogicType.Temperature&lt;br /&gt;
loop:&lt;br /&gt;
pop r1&lt;br /&gt;
l r0 myDevice r1&lt;br /&gt;
...&lt;br /&gt;
bgtz sp loop #loop until the Stack is empty}}&lt;br /&gt;
&lt;br /&gt;
==Network Referencing / Channels==&lt;br /&gt;
&lt;br /&gt;
All cable networks have 8 Channels which can have data loaded from/stored to via a device and connection reference. Connections for each supported device are listed in the stationpedia. All &#039;connections&#039; a device can make are a connection (pipe, chute, cable), but only cable networks have channels.&lt;br /&gt;
&lt;br /&gt;
The 8 channels (Channel0 to Channel7) are however volatile, in that data is destroyed if any part of the cable network is changed, removed, or added to, and also whenever the world is exited. All these channels default to NaN. Strictly speaking, they default to what we would call &amp;quot;quiet NaN&amp;quot;, in that its not an error it simply means its not a number yet. Recommend you use these channels for reading and writing between networks, rather than as a data store. This effectively means an IC can read all the networks for all devices to connected to it, so not just their own local network, but any networks any device they can reference is connected to.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# d0 is device zero, and the :0 refers&lt;br /&gt;
# to that device&#039;s 0 connection&lt;br /&gt;
l r0 d0:0 Channel0}}&lt;br /&gt;
&lt;br /&gt;
For example: on an IC Housing, the 0 connection is the data port and 1 is power, so you could write out r0 to Channel0 of the power network of the Housing using &amp;lt;code&amp;gt;s db:1 Channel0 r0&amp;lt;/code&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#read all 8 channels with a loop and&lt;br /&gt;
#place the values in r0 to r7&lt;br /&gt;
move r15 LogicType.Channel0 #LogicType integer&lt;br /&gt;
move r14 0 #pointer for indirect referencing&lt;br /&gt;
loop:&lt;br /&gt;
l rr14 db:0 r15&lt;br /&gt;
add r15 r15 1 #next channel&lt;br /&gt;
add r14 r14 1 #next register&lt;br /&gt;
ble r15 LogicType.Channel7 loop&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Logic gates, Bitwise and Logical==&lt;br /&gt;
&lt;br /&gt;
All logic gates in MIPS have a bitwise behavior. The available gates are NOT, AND, OR, XOR and NOR (XNOR and NAND are missing).&lt;br /&gt;
&lt;br /&gt;
In Bitwise operations, each bit is matched separately, which includes the sign bit.&lt;br /&gt;
&lt;br /&gt;
To understand what is going on with bitwise operations, a little bit of computer theory is needed. In Stationeers each register uses 64 bits for integer values (a number without decimals), where the 64th bit is the sign-bit (0 for positive and 1 for negative). Since the number 0 is counted as a positive value, this gives each register a range of (2^63 - 1) to -2^63. Negative numbers also behave according to Two&#039;s complement (https://en.wikipedia.org/wiki/Two%27s_complement). Which means that a number with a sign-bit of 1 will have all of its number bits flipped as well, so that the decimal value of -1 is represented by a binary value of sixtyfour 1&#039;s (this is the smallest possible negative integer since zero counts as a positive integer).&lt;br /&gt;
&lt;br /&gt;
MIPS have binary notation (https://en.wikipedia.org/wiki/Binary_number) that is activated by placing a % in front of the number. The _ characters are ignored and only used for readability.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;not r0 0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 0 = %00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# flip all bits&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# -1 = %11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals -1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;and r0 3 6&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 3 = %011&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 6 = %110&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# only the bits in the &amp;quot;2&amp;quot; position are matching&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals %010 = 2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operations can still be performed via alternative instructions. But these are not perfect substitutes, they treat negative values differently, and some can produce non-binary outputs. When using these, keep in mind that devices that wants a binary value will treat any non-binary values like this: &amp;gt;= 1 counts as &amp;quot;1&amp;quot; and &amp;lt;1 counts as &amp;quot;0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 = result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r1 = input A&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r2 = input B&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOT = seqz r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical AND = min r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical OR = max r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XOR = sne r0 r1 r2 (only for binary inputs)&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NAND = not and&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOR = not or&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XNOR = not xor&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging advices==&lt;br /&gt;
The value stored in a register or variable can easily be displayed by writing it to the Setting parameter of the IC housing. This has no side effects unless the housing is an [[Air Conditioner]]. To see the value, just stand close to the IC housing and look directly at the housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting r0&amp;lt;/code&amp;gt;. # sets/writes the value of register &#039;&#039;&#039;r0&#039;&#039;&#039; into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
To check if a certain block of code is executed, use the above trick but with a random number that you choose, like the line number.&amp;lt;br&amp;gt; This example will display the number 137 on the IC housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting 137&amp;lt;/code&amp;gt;  # sets/writes the number 137 into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Always use unique names for labels. When a label is named after a IC10 keyword like &amp;quot;Temperature:&amp;quot; or &amp;quot;Setting:&amp;quot; the original meaning of the keyword is overwritten, so when an instruction tries to use it an error will occur.&lt;br /&gt;
&lt;br /&gt;
A [[Cartridge#Configuration|configuration cartridge]] installed in a [[Handheld_Tablet|tablet]]  can be used to see all available values and configuration parameter for all devices you focus on.&lt;br /&gt;
&lt;br /&gt;
==Learning IC10==&lt;br /&gt;
IC10 can be difficult to get started with. So here is a list of instructions that are useful for beginners. These can be used to write many different scripts.&lt;br /&gt;
&lt;br /&gt;
General:&lt;br /&gt;
* &amp;lt;code&amp;gt;alias&amp;lt;/code&amp;gt; make the script easier to read by assigning a name to a register or device, example: &amp;lt;code&amp;gt;alias rTemperature r15&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;label:&amp;lt;/code&amp;gt; where &amp;quot;label&amp;quot; can be replaced with almost any word, jump and branch instructions can use these in place of line numbers, example: &amp;lt;code&amp;gt;start:&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; pause for 1-tick and then resume, if not used the script will automatically pause for 1-tick after 128 lines&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Jumps:&lt;br /&gt;
*&amp;lt;code&amp;gt;j someLabelName&amp;lt;/code&amp;gt; jump to line with &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;jal someLabelName&amp;lt;/code&amp;gt; stores the next line number into the register ra (return address) and then jump to &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt; jump to register ra (return address)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Branching (jump-if):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;beq a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if &#039;&#039;&#039;a&#039;&#039;&#039; is equal to &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039;  (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bne a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; not-equal &#039;&#039;&#039;b&#039;&#039;&#039; goto  &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bgt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; greater than &#039;&#039;&#039;b&#039;&#039;&#039; goto   &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;blt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; less than &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
The suffix -al can be added to each of these (example: beqal) to save the &#039;&#039;&#039;next&#039;&#039;&#039; line number into the &amp;quot;return address&amp;quot; register. this is called using &amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Device interactions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
l (load)&lt;br /&gt;
lb (load batch, requires one of the following: 0(Average) / 1(Sum) / 2(Minimum) / 3(Maximum))&lt;br /&gt;
ls (load slot)&lt;br /&gt;
s (store)&lt;br /&gt;
sb (store batch)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Logic and Math:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seqz (common NOT-gate: turns 0 into 1, and all other values into 0)&lt;br /&gt;
move&lt;br /&gt;
add (addition)&lt;br /&gt;
sub (subtraction)&lt;br /&gt;
mul (multiplication)&lt;br /&gt;
div (division)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Common device variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On (1 is on, 0 is off)&lt;br /&gt;
Open (1 is open, 0 is closed)&lt;br /&gt;
Setting (meaning varies between devices, example: a LED display(console) will show this value)&lt;br /&gt;
Activate (1 usually means running, example: a Daylight sensor is 1 when the sun shines on it)&lt;br /&gt;
Temperature (in Kelvin, Celsius - 273.15)&lt;br /&gt;
Pressure (in kPa)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Notes:&lt;br /&gt;
&amp;lt;br&amp;gt;-All instructions and variables can be seen in-game in the IC editor window by clicking the &amp;quot;f&amp;quot;, &amp;quot;x&amp;quot; and &amp;quot;s(x)&amp;quot; buttons on the top right.&lt;br /&gt;
&amp;lt;br&amp;gt;-The stationpedia is the best source to see which variables are available to each device.&lt;br /&gt;
&amp;lt;br&amp;gt;-Most scripts are loops, they end with a jump instruction that leads back up to the start. Otherwise they will just run once and then stop.&lt;br /&gt;
&lt;br /&gt;
Two practice scripts:&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Night Light: Load &amp;quot;Activate&amp;quot; from a Daylight sensor, flip the value with a NOT-gate, store the value to the &amp;quot;On&amp;quot; variable of one or more lights.&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Wall Cooler: Read &amp;quot;Temperature&amp;quot; from a Gas Sensor. Branch if the value is greater than X, turn on the cooler. Branch if the value is less than Y, turn off the cooler. (Wall coolers need a minimum of 12.5 kPa pressure in the connected pipe)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Accessing devices via batch or ReferenceId ==&lt;br /&gt;
&lt;br /&gt;
The IC housing has 6 pins you can use to configure the devices it&lt;br /&gt;
uses.  This provides flexibility to let the installer configure which&lt;br /&gt;
devices will be controlled by the IC.&lt;br /&gt;
&lt;br /&gt;
Alternatives for accessing devices include the batch load/store and&lt;br /&gt;
the ReferenceId load/store instructions.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the average charge ratio across station batteries&lt;br /&gt;
lb r0 HASH(&amp;quot;StructureBattery&amp;quot;) Ratio Average&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the ReferenceId for the sorter named &amp;quot;Sorter Corn&amp;quot;&lt;br /&gt;
lbn r1 HASH(&amp;quot;StructureLogicSorter&amp;quot;) HASH(&amp;quot;Sorter Corn&amp;quot;) ReferenceId Maximum&lt;br /&gt;
ble r1 ninf ra&lt;br /&gt;
#use the ReferenceId to set that sorter&#039;s mode.&lt;br /&gt;
sd r1 Mode 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Using the 6 configuration pins makes it easy to write reusable MIPS&lt;br /&gt;
scripts where the installer uses the pins to select the devices that&lt;br /&gt;
will be managed.&lt;br /&gt;
&lt;br /&gt;
Using batch-name instructions frees you from the hassle of adjusting&lt;br /&gt;
the pins, but requires you to name the devices via the [[Labeller]].  It&lt;br /&gt;
can also allow you to control more than 6 devices.&lt;br /&gt;
&lt;br /&gt;
=== Batch instructions ===&lt;br /&gt;
&lt;br /&gt;
The batch instructions can address multiple devices only via their &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; generated from the prefab name using the `HASH(&amp;quot;Name&amp;quot;)` macro or copied directly from the [[Stationpedia]]. A prefab hash is always an integer. All devices that can be read with logic contain the logic value &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; and &#039;&#039;&#039;NameHash&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
See [[#Slot.2FLogic_.2F_Batched|Batched instructions]] for a comprehensive list of all batch instructions.&lt;br /&gt;
&lt;br /&gt;
[[#sb|sb]], [[#sbn|sbn]], [[#sbs|sbs]], (no sbns)&amp;lt;br&amp;gt;&lt;br /&gt;
[[#lb|lb]], [[#lbs|lbs]], [[#lbn|lbn]], [[#lbns|lbns]]&lt;br /&gt;
&lt;br /&gt;
=== Direct reference instructions ===&lt;br /&gt;
&lt;br /&gt;
Direct reference instructions can address a specific device via its &#039;&#039;&#039;ReferenceId&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[#clrd|clrd]], [[#getd|getd]], [[#putd|putd]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[#ld|ld]], [[#sd|sd]], (no slot access via reference ID)&lt;br /&gt;
&lt;br /&gt;
=Instructions=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
See [[IC10/instructions]]&lt;br /&gt;
&lt;br /&gt;
{{:IC10/instructions}}&lt;br /&gt;
&lt;br /&gt;
[https://www.cs.tufts.edu/comp/140/lectures/Day_3/mips_summary.pdf Other examples]&lt;br /&gt;
&lt;br /&gt;
== Conditional functions cheatsheet ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! suffix !! description !! branch to line !! branch and store return address !! relative jump to line !! set register&lt;br /&gt;
|-&lt;br /&gt;
| prefix: ||  || b- || b-al || br- || s-&lt;br /&gt;
|-&lt;br /&gt;
|  || unconditional || j    || jal    || jr    || &lt;br /&gt;
|-&lt;br /&gt;
| -eq  || if a == b || beq  || beqal  || breq  || seq&lt;br /&gt;
|-&lt;br /&gt;
| -eqz || if a == 0 || beqz || beqzal || breqz || seqz&lt;br /&gt;
|-&lt;br /&gt;
| -ge  || if a &amp;gt;= b || bge  || bgeal  || brge  || sge&lt;br /&gt;
|-&lt;br /&gt;
| -gez || if a &amp;gt;= 0 || bgez || bgezal || brgez || sgez&lt;br /&gt;
|-&lt;br /&gt;
| -gt  || if a &amp;gt; b  || bgt  || bgtal  || brgt  || sgt&lt;br /&gt;
|-&lt;br /&gt;
| -gtz || if a &amp;gt; 0  || bgtz || bgtzal || brgtz || sgtz&lt;br /&gt;
|-&lt;br /&gt;
| -le  || if a &amp;lt;= b || ble  || bleal  || brle  || sle&lt;br /&gt;
|-&lt;br /&gt;
| -lez || if a &amp;lt;= 0 || blez || blezal || brlez || slez&lt;br /&gt;
|-&lt;br /&gt;
| -lt  || if a &amp;lt; b  || blt  || bltal  || brlt  || slt&lt;br /&gt;
|-&lt;br /&gt;
| -ltz || if a &amp;lt; 0  || bltz || bltzal || brltz || sltz&lt;br /&gt;
|-&lt;br /&gt;
| -ne  || if a != b || bne  || bneal  || brne  || sne&lt;br /&gt;
|-&lt;br /&gt;
| -nez || if a != 0 || bnez || bnezal || brnez || snez&lt;br /&gt;
|-&lt;br /&gt;
| -nan || if a == NaN || bnan ||  || brnan || snan&lt;br /&gt;
|-&lt;br /&gt;
| -nanz || if a != NaN ||  ||  || || snanz&lt;br /&gt;
|-&lt;br /&gt;
| -dns || if device d is not set          || bdns || bdnsal || brdns || sdns&lt;br /&gt;
|-&lt;br /&gt;
| -dse || if device d is set              || bdse || bdseal || brdse || sdse&lt;br /&gt;
|-&lt;br /&gt;
| -ap  || if a approximately equals b     || bap  || bapal  || brap  || sap&lt;br /&gt;
|-&lt;br /&gt;
| -apz || if a approximately equals 0     || bapz || bapzal || brapz || sapz&lt;br /&gt;
|-&lt;br /&gt;
| -na  || if a not approximately equals b || bna  || bnaal  || brna  || sna&lt;br /&gt;
|-&lt;br /&gt;
| -naz || if a not approximately equals 0 || bnaz || bnazal || brnaz || snaz&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All &amp;lt;code&amp;gt;b-&amp;lt;/code&amp;gt; commands require target line as last argument, all &amp;lt;code&amp;gt;s-&amp;lt;/code&amp;gt; commands require register to store result as first argument. All &amp;lt;code&amp;gt;br-&amp;lt;/code&amp;gt; commands require number to jump relatively as last argument. e.g. &amp;lt;code&amp;gt;breq a b 3&amp;lt;/code&amp;gt; means if a=b then jump to 3 lines after.&lt;br /&gt;
&lt;br /&gt;
All approximate functions require additional argument denoting how close two numbers need to be considered equal. E.g.: &amp;lt;code&amp;gt;sap r0 100 101 0.01&amp;lt;/code&amp;gt; will consider 100 and 101 almost equal (not more than 1%=0.01 different) and will set r0 to 1. The exact formula is &amp;lt;code&amp;gt;if abs(a - b) &amp;lt;= max(c * max(abs(a), abs(b)), float.epsilon * 8)&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;-ap&amp;lt;/code&amp;gt; and is similar for other approximate functions.&lt;br /&gt;
&lt;br /&gt;
https://en.wikipedia.org/wiki/Machine_epsilon&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
  FLT_EPSILON = 2^(−23) ≈ 1.19e−07;        &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;float (32 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
  DBL_EPSILON = 2^(−52) ≈ 2.20e−16;        &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;double (64 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(100 - 101) &amp;lt;= max(0.01 * max(abs(100), abs(101)), float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(-1) &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if 1 &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, FLT_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, DBL_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 1.19e−07 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 2.20e−16 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.000000952)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.00000000000000176)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Device Variables==&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Activate&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Activate&lt;br /&gt;
:1 if device is activated (usually means running), otherwise 0&lt;br /&gt;
:&amp;lt;code&amp;gt;l r0 d0 Activate # sets r0 to 1 if on or 0 if off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;AirRelease&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;AirRelease&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
:    The current charge the device has.&lt;br /&gt;
&amp;lt;div id=&amp;quot;CLearMemory&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ClearMemory&lt;br /&gt;
:    When set to 1, clears the counter memory (e.g. ExportCount).  Will set itself back to 0 when triggered.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Color&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#212AA5;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;0 (or lower) = Blue&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#7B7B7B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;1 = Grey &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#3F9B39;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;2 = Green &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FF662B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;3 = Orange &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E70200;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;4 = Red &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FFBC1B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;5 = Yellow &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E7E7E7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;6 = White &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#080908;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;7 = Black &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#633C2B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;8 = Brown &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#63633F;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;9 = Khaki &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E41C99;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;10 = Pink &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#732CA7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;11 (or higher) = Purple &lt;br /&gt;
&amp;lt;div id=&amp;quot;CompletionRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;CompletionRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorLevel&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorLevel&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorSpeed&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorSpeed&lt;br /&gt;
&amp;lt;div id=&amp;quot;Error&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Error&lt;br /&gt;
:	1 if device is in error state, otherwise 0&lt;br /&gt;
&amp;lt;div id=&amp;quot;ExportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ExportCount&lt;br /&gt;
:    How many items exporfted since last ClearMemory.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Filtration&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Filtration&lt;br /&gt;
:	The current state of the filtration system.  For example filtration = 1 for a Hardsuit when filtration is On.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Harvest&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Harvest&lt;br /&gt;
:	Performs the harvesting action for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Harvest 1 # Performs 1 harvest action on device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Horizontal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Horizontal&lt;br /&gt;
&amp;lt;div id=&amp;quot;HorizontalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;HorizontalRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Idle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Idle&lt;br /&gt;
&amp;lt;div id=&amp;quot;ImportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ImportCount&lt;br /&gt;
&amp;lt;div id=&amp;quot;Lock&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Lock&lt;br /&gt;
&amp;lt;div id=&amp;quot;Maximum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Maximum&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mode&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mode&lt;br /&gt;
&amp;lt;div id=&amp;quot;On&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;On&lt;br /&gt;
&amp;lt;div id=&amp;quot;Open&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Open&lt;br /&gt;
&amp;lt;div id=&amp;quot;Output&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Output&lt;br /&gt;
&amp;lt;div id=&amp;quot;Plant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Plant&lt;br /&gt;
:    Performs the planting operation for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Plant 1 # Plants one crop in device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionX&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionY&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Power&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Power&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerActual&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerActual&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerPotential&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerPotential&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerRequired&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerRequired&lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureExternal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureExternal&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureInteral&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureInteral&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureSetting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureSetting&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
:	Total quantity in the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Ratio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Ratio&lt;br /&gt;
:	Context specific value depending on device, 0 to 1 based ratio.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioCarbonDioxide&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioCarbonDioxide&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioNitrogen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioNitrogen&lt;br /&gt;
:	The ratio of nitrogen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioOxygen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioOxygen&lt;br /&gt;
:	The ratio of oxygen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioPollutant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioPollutant&lt;br /&gt;
:	The ratio of pollutant in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioVolatiles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioVolatiles&lt;br /&gt;
:	The ratio of volatiles in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioWater&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioWater&lt;br /&gt;
:	The ratio of water in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Reagents&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Reagents&lt;br /&gt;
&amp;lt;div id=&amp;quot;RecipeHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RecipeHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequestHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequestHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequiredPower&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequiredPower&lt;br /&gt;
&amp;lt;div id=&amp;quot;Setting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Setting&lt;br /&gt;
&amp;lt;div id=&amp;quot;SolarAngle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;SolarAngle&lt;br /&gt;
:    Solar angle of the device.&lt;br /&gt;
:  &amp;lt;code&amp;gt;l r0 d0 SolarAngle # Sets r0 to the solar angle of d0.&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;TemperatureSettings&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TemperatureSettings&lt;br /&gt;
&amp;lt;div id=&amp;quot;TotalMoles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TotalMoles&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityMagnitude&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityMagnitude&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeX&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeY&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Vertical&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Vertical&lt;br /&gt;
:	Vertical setting of the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;VerticalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VerticalRatio&lt;br /&gt;
:	Ratio of vertical setting for device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Volume&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Volume&lt;br /&gt;
:	Returns the device atmosphere volume&lt;br /&gt;
&lt;br /&gt;
==Slot Variables==&lt;br /&gt;
In general (exceptions exist such as filtration units) slots are assigned as follows.&lt;br /&gt;
:Slot 0: Import&lt;br /&gt;
:Slot 1: Export&lt;br /&gt;
:Slot 2: Inside Machine&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Occupied&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Occupied&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 2 Occupied #Stores 1 in r0 if d0 has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vOccupied dThisVictim 2 Occupied #stores 1 in vOccupied if dThisVictim has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;OccupantHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;OccupantHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
&amp;lt;div id=&amp;quot;Damage&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Damage&lt;br /&gt;
&amp;lt;div id=&amp;quot;Efficiency&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Efficiency&lt;br /&gt;
&amp;lt;div id=&amp;quot;Health&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Health&lt;br /&gt;
&amp;lt;div id=&amp;quot;Growth&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Growth&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Growth # Store the numerical growth stage of d0 in r0&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
&amp;lt;div id=&amp;quot;ChargeRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ChargeRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Class&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Class&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureWaste&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureWaste&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureAir&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureAir&lt;br /&gt;
&amp;lt;div id=&amp;quot;MaxQuantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;MaxQuantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mature&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Mature # Store 1 in r0 if d0 has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vMature dThisVictim 0 Mature # Store 1 in vMature if dThisVictim has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Previous examples were obsolete due to game changes, or confusing, they have been moved into the Discussions section&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Harvie automation===&lt;br /&gt;
This script uses the batch instruction &amp;lt;code&amp;gt;sb ...&amp;lt;/code&amp;gt; to control all Harvie devices on the network. But only one Harvie and one Tray will be the &#039;&#039;master&#039;&#039; and have their values read, the rest of the Harvies will repeat exactly what this unit does. Some problems with this design is that different types of crops mature at different speeds, and if seeds were manually planted and the master unit recieved the first seed, the harvesting action will be performed too early on all the other plants since they are growing a few seconds slower.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Automated Harvie Script}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Automated Harvie Script}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias dHarvie d0&lt;br /&gt;
alias dTray d1&lt;br /&gt;
&lt;br /&gt;
alias rHarvieHash r8&lt;br /&gt;
alias rTrayHash r9&lt;br /&gt;
l rHarvieHash dHarvie PrefabHash&lt;br /&gt;
l rTrayHash dTray PrefabHash&lt;br /&gt;
&lt;br /&gt;
main:&lt;br /&gt;
yield&lt;br /&gt;
#read plant data from the Tray&lt;br /&gt;
ls r0 dTray 0 Mature&lt;br /&gt;
#harvestable plants return 1, young plants return 0&lt;br /&gt;
#nothing planted returns -1&lt;br /&gt;
beq r0 -1 plantCrop&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
ls r0 dTray 0 Seeding&lt;br /&gt;
#seeds available returns 1, all seeds picked returns 0&lt;br /&gt;
#plants too young or old for seeds returns -1&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
plantCrop:&lt;br /&gt;
#stop the planting if no seeds available&lt;br /&gt;
#otherwise it will plant nothing repeatedly&lt;br /&gt;
ls r0 dHarvie 0 Occupied&lt;br /&gt;
beq r0 0 main&lt;br /&gt;
sb rHarvieHash Plant 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
harvestCrop:&lt;br /&gt;
sb rHarvieHash Harvest 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
### End Script ###&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Solar Panel 2-axis tracking===&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Solar Panel 2-axis tracking}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Solar Panel 2-axis tracking}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#2 Axis Solar Tracking adapted from CowsAreEvil.&lt;br /&gt;
#Place all panels in uniform manner.&lt;br /&gt;
#Set one to 15 Vertical(Min value). 0 Horizontal.&lt;br /&gt;
#Take note direction panel faces.&lt;br /&gt;
#Place daylight sensor flat pointing in the direction&lt;br /&gt;
#the panel now faces. (Cable port facing opposite)&lt;br /&gt;
&lt;br /&gt;
#Alias the sensor to d0&lt;br /&gt;
alias sensor d0&lt;br /&gt;
&lt;br /&gt;
# define the Panel variants&lt;br /&gt;
define Heavy -934345724&lt;br /&gt;
define HeavyDual -1545574413&lt;br /&gt;
define Solar -2045627372&lt;br /&gt;
define SolarDual -539224550&lt;br /&gt;
&lt;br /&gt;
start:&lt;br /&gt;
yield&lt;br /&gt;
#Check for daylight.&lt;br /&gt;
l r0 sensor Activate&lt;br /&gt;
beqz r0 reset&lt;br /&gt;
#Read the Horizontal data.&lt;br /&gt;
l r0 sensor Horizontal&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Horizontal r0&lt;br /&gt;
sb HeavyDual Horizontal r0&lt;br /&gt;
sb Solar Horizontal r0&lt;br /&gt;
sb SolarDual Horizontal r0&lt;br /&gt;
#Read the Vertical data and subtract 90&lt;br /&gt;
l r0 sensor Vertical&lt;br /&gt;
sub r0 90 r0&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Vertical r0&lt;br /&gt;
sb HeavyDual Vertical r0&lt;br /&gt;
sb Solar Vertical r0&lt;br /&gt;
sb SolarDual Vertical r0&lt;br /&gt;
j start&lt;br /&gt;
&lt;br /&gt;
reset:&lt;br /&gt;
yield&lt;br /&gt;
sb Heavy Horizontal 270 #Edit this to face sunrise.&lt;br /&gt;
sb HeavyDual Horizontal 270 #Edit this&lt;br /&gt;
sb Solar Horizontal 270 #Edit this&lt;br /&gt;
sb SolarDual Horizontal 270 #Edit this&lt;br /&gt;
sb Heavy Vertical 0&lt;br /&gt;
sb HeavyDual Vertical 0&lt;br /&gt;
sb Solar Vertical 0&lt;br /&gt;
sb SolarDual Vertical 0&lt;br /&gt;
sleep 10&lt;br /&gt;
j start&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===IC10 Schmitt Trigger - Sensor Range Based Device Toggle===&lt;br /&gt;
This script demonstrates the IC10 style Schmitt Trigger Pattern in basic examples using the &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; instruction with its ternary condition to toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state based on a range of sensor readings.  Examples for both styles are provided below, i.e. &#039;cooling&#039; or &#039;heating&#039;, for &#039;below min&#039; or &#039;greater than max&#039; style range-based toggle.  A temperature based control is shown in the examples, but any sensor reading could be used to dynamically toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state such pressure, charge ratio, solar angle, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, IC10 Schmitt Trigger Pattern}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, IC10 Schmitt Trigger Pattern}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Standard - i.e. &amp;quot;cooling&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# higher than TempMax and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# higher than TempMin, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature lower than&lt;br /&gt;
# TempMin, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example1:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMin TempMax&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 sgt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Inverted - i.e. &amp;quot;heating&amp;quot;&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# lower than TempMin and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# lower than TempMax, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature higher than&lt;br /&gt;
# TempMax, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example2:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMax TempMin&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 slt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example2&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Example experiment: how many lines of code are executed each tick?===&lt;br /&gt;
To determine this, a script without &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; will be used. It should have as few lines as possible (so no labels are used, but a reset value at the top will be needed) and count the number of lines, the IC Housing will be used to display the result.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 1   #the first line has number 0&lt;br /&gt;
add r0 r0 3&lt;br /&gt;
s db Setting r0&lt;br /&gt;
j 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Result (the numbers appears every 0.5 seconds):&lt;br /&gt;
&amp;lt;br&amp;gt;127&lt;br /&gt;
&amp;lt;br&amp;gt;256 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;385 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;511 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;640 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;769 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;895 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;1024 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;1153 (+129)&lt;br /&gt;
&lt;br /&gt;
There is a repeating +129, +129, +126 sequence, a hint that the real value is 128. Which also happens to be the number of lines in a script, which makes sense. A variation of this experiment will show that empty rows are also counted towards this number.&lt;br /&gt;
&lt;br /&gt;
===Push &amp;amp; Pop return address when calling multiple levels of functions===&lt;br /&gt;
More advanced scripts, or scripts that wish to be more generic, may want to allow calling more than one level of function. Allowing this requires pushing the current &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register before calling the function, then popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; back afterward.&lt;br /&gt;
&lt;br /&gt;
For example, imagine that the main loop of the code wants to call function &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, which would calculate the panels&#039; orientations, then place them in &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;, and then in turn itself call &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, which would set the orientations of all panels based on the precomputed values of &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;. Doing so requires &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; to push &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, as show in the code below.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
orientPanelsToStar:&lt;br /&gt;
# Save return address set by the &#039;jal&#039; instruction&lt;br /&gt;
push ra&lt;br /&gt;
&lt;br /&gt;
# ...Calculate panels&#039; orientation, for example leaving the results in r0 and r1...&lt;br /&gt;
&lt;br /&gt;
# Now call orientPanelsTo to actually set the panels&#039; orientation&lt;br /&gt;
# based on the computed values of r0 and r1.&lt;br /&gt;
jal orientPanelsTo&lt;br /&gt;
&lt;br /&gt;
# ...Call other functions here if desired...&lt;br /&gt;
&lt;br /&gt;
# Restore the return address of orientPanelsToStar itself&lt;br /&gt;
pop ra&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
&lt;br /&gt;
##########&lt;br /&gt;
&lt;br /&gt;
orientPanelsTo:&lt;br /&gt;
# ...Actually set panels&#039; orientation...&lt;br /&gt;
&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This code would behave incorrectly if &amp;lt;code&amp;gt;push ra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pop ra&amp;lt;/code&amp;gt; were not present: within &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, doing &amp;lt;code&amp;gt;jal orientPanelsTo&amp;lt;/code&amp;gt; would replace the current value of the &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register, permanently erasing where &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; itself should jump back to once done. Pushing and popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; effectively saves its value until we need it again.&lt;br /&gt;
&lt;br /&gt;
(A tempting but wrong approach to &#039;saving&#039; &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; would be to &amp;lt;code&amp;gt;move&amp;lt;/code&amp;gt; it within a different register (e.g. &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt;) before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, however that only permits two levels of functions, since if &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt; itself wants to call another function, it would not be able to use &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; to save its &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register since &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; already saves &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;&#039;s return address. Just pushing/popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; fixes all issues, allowing for a ginormous maximum function call depth of 512!)&lt;br /&gt;
&lt;br /&gt;
As a last note, if the script will push/pop values like &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt;, starting the script by clearing the stack (which where push/pop move the data to) by running &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; is advisable, unless the IC10 chip is not inserted inside an IC Housing (e.g. inserted in the slot of an Air Conditioner), since &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; will cause an error in this case. To do so, run &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; before the script&#039;s main loop.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
----&lt;br /&gt;
* Stationeers online IC10 Emulators so you can develop your code without repeatedly dying in game&lt;br /&gt;
** [https://ic10.dev/] Stationeers Code Simulator&lt;br /&gt;
** [https://ic10emu.dev] Stationeers IC10 Editor &amp;amp; Emulator - A feature packed code editor for Stationeers IC10 code, paired with a robust debugger and emulator. Edit, test, and share code.&lt;br /&gt;
** [https://stationeering.com/tools/ic] Stationeering provides a simulation of the IC10 chip inside Stationeers. IDE with error checking, full visibility of stack and registers.&lt;br /&gt;
* [http://www.easy68k.com/] EASy68K is a 68000 Structured Assembly Language IDE.&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=Traineratwot.stationeers-ic10] syntax highlighting for IC10 MIPS for Visual Studio Code (updated Feb 10th 2022)&lt;br /&gt;
* [https://pastebin.com/6Uw1KSRN] syntax highlighting for IC10 MIPS for KDE kwrite/kate text editor&lt;br /&gt;
* [https://drive.google.com/file/d/1yEsJ-u94OkuMQ8K6fY7Ja1HNpLcAdjo_/view] syntax highlighting for IC10 MIPS for Notepad++&lt;br /&gt;
* [https://drive.google.com/file/d/1Xrv5U0ZI5jDcPv7yX7EAAxaGk5hKP0xO/view?usp=sharing] syntax highlighting for IC10 MIPS for Notepad++ (updated: 11/08/2022)&lt;br /&gt;
* [https://pastebin.com/3kmGy0NN] syntax highlighting for IC10 MIPS for Notepad++ (updated: 23/03/2024)&lt;br /&gt;
* [https://github.com/SnorreSelmer/stationeers_ic10/blob/main/README.md] Repo with a lot of code examples&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Index=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|+Functions &lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#abs|abs]]&lt;br /&gt;
*[[#add|add]]&lt;br /&gt;
*[[#alias|alias]]&lt;br /&gt;
*[[#and|and]]&lt;br /&gt;
*[[#beq|beq]]&lt;br /&gt;
*[[#bgez|bgez]]&lt;br /&gt;
*[[#bgtz|bgtz]]&lt;br /&gt;
*[[#blez|blez]]&lt;br /&gt;
*[[#bltz|bltz]]&lt;br /&gt;
*[[#bne|bne]]&lt;br /&gt;
*[[#breq|breq]]&lt;br /&gt;
*[[#brgez|brgez]]&lt;br /&gt;
*[[#brgtz|brgtz]]&lt;br /&gt;
*[[#brlez|brlez]]&lt;br /&gt;
*[[#brltz|brltz]]&lt;br /&gt;
*[[#brne|brne]]&lt;br /&gt;
*[[#ceil|cell]]&lt;br /&gt;
*[[#div|div]]&lt;br /&gt;
*[[#exp|exp]]&lt;br /&gt;
*[[#floor|floor]]&lt;br /&gt;
*[[#j|j]]&lt;br /&gt;
*[[#jr|jr]]&lt;br /&gt;
*[[#l|l]]&lt;br /&gt;
*[[#log|log]]&lt;br /&gt;
*[[#ls|ls]]&lt;br /&gt;
*[[#max|max]]&lt;br /&gt;
*[[#min|min]]&lt;br /&gt;
*[[#mod|mod]]&lt;br /&gt;
*[[#move|move]]&lt;br /&gt;
*[[#mul|mul]]&lt;br /&gt;
*[[#nor|nor]]&lt;br /&gt;
*[[#or|or]]&lt;br /&gt;
*[[#rand|rand]]&lt;br /&gt;
*[[#round|round]]&lt;br /&gt;
*[[#s|s]]&lt;br /&gt;
*[[#slt|slt]]&lt;br /&gt;
*[[#sqrt|sqrt]]&lt;br /&gt;
*[[#sub|sub]]&lt;br /&gt;
*[[#trunc|trunc]]&lt;br /&gt;
*[[#xor|xor]]xor&lt;br /&gt;
*[[#yield|yield]]&lt;br /&gt;
*[[##|#]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|+Device Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Activate|Activate]]&lt;br /&gt;
*[[#AirRelease|AirRelease]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#CLearMemory|CLearMemory]]&lt;br /&gt;
*[[#Color|Color]]&lt;br /&gt;
*[[#CompletionRatio|CompletionRatio]]&lt;br /&gt;
*[[#ElevatorLevel|ElevatorLevel]]&lt;br /&gt;
*[[#ElevatorSpeed|ElevatorSpeed]]&lt;br /&gt;
*[[#Error|Error]]&lt;br /&gt;
*[[#ExportCount|ExportCount]]&lt;br /&gt;
*[[#Filtration|Filtration]]&lt;br /&gt;
*[[#Harvest|Harvest]]&lt;br /&gt;
*[[#Horizontal|Horizontal]]&lt;br /&gt;
*[[#HorizontalRatio|HorizontalRatio]]&lt;br /&gt;
*[[#Idle|Idle]]&lt;br /&gt;
*[[#ImportCount|ImportCount]]&lt;br /&gt;
*[[#Lock|Lock]]&lt;br /&gt;
*[[#Maximum|Maximum]]&lt;br /&gt;
*[[#Mode|Mode]]&lt;br /&gt;
*[[#On|On]]&lt;br /&gt;
*[[#Open|Open]]&lt;br /&gt;
*[[#Output|Output]]&lt;br /&gt;
*[[#Plant|Plant]]&lt;br /&gt;
*[[#PositionX|PositionX]]&lt;br /&gt;
*[[#PositionY|PositionY]]&lt;br /&gt;
*[[#PositionZ|PositionZ]]&lt;br /&gt;
*[[#Power|Power]]&lt;br /&gt;
*[[#PowerActual|PowerActual]]&lt;br /&gt;
*[[#PowerPotential|PowerPotential]]&lt;br /&gt;
*[[#PowerRequired|PowerRequired]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#PressureExternal|PressureExternal]]&lt;br /&gt;
*[[#PressureInteral|PressureInteral]]&lt;br /&gt;
*[[#PressureSetting|PressureSetting]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Ratio|Ratio]]&lt;br /&gt;
*[[#RatioCarbonDioxide|RatioCarbonDioxide]]&lt;br /&gt;
*[[#RatioNitrogen|RatioNitrogen]]&lt;br /&gt;
*[[#RatioOxygen|RatioOxygen]]&lt;br /&gt;
*[[#RatioPollutant|RatioPollutant]]&lt;br /&gt;
*[[#RatioVolatiles|RatioVolatiles]]&lt;br /&gt;
*[[#RatioWater|RatioWater]]&lt;br /&gt;
*[[#Reagents|Reagents]]&lt;br /&gt;
*[[#RecipeHash|RecipeHash]]&lt;br /&gt;
*[[#RequestHash|RequestHash]]&lt;br /&gt;
*[[#RequiredPower|RequiredPower]]&lt;br /&gt;
*[[#Setting|Setting]]&lt;br /&gt;
*[[#SolarAngle|SolarAngle]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#TemperatureSettings|TemperatureSettings]]&lt;br /&gt;
*[[#TotalMoles|TotalMoles]]&lt;br /&gt;
*[[#VelocityMagnitude|VelocityMagnitude]]&lt;br /&gt;
*[[#VelocityRelativeX|VelocityRelativeX]]&lt;br /&gt;
*[[#VelocityRelativeY|VelocityRelativeY]]&lt;br /&gt;
*[[#VelocityRelativeZ|VelocityRelativeZ]]&lt;br /&gt;
*[[#Vertical|Vertical]]&lt;br /&gt;
*[[#VerticalRatio|VerticalRatio]]&lt;br /&gt;
*[[#Volume|Volume]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|+Slot Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Occupied|Occupied]]&lt;br /&gt;
*[[#OccupantHash|OccupantHash]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Damage|Damage]]&lt;br /&gt;
*[[#Efficiency|Efficiency]]&lt;br /&gt;
*[[#Health|Health]]&lt;br /&gt;
*[[#Growth|Growth]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#ChargeRatio|ChargeRatio]]&lt;br /&gt;
*[[#Class|Class]]&lt;br /&gt;
*[[#PressureWaste|PressureWaste]]&lt;br /&gt;
*[[#PressureAir|PressureAir]]&lt;br /&gt;
*[[#MaxQuantity|MaxQuantity]]&lt;br /&gt;
*[[#Mature|Mature]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=User:SemlerPDX&amp;diff=25477</id>
		<title>User:SemlerPDX</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=User:SemlerPDX&amp;diff=25477"/>
		<updated>2026-01-07T23:11:10Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: YT link update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:SemlerPDX Logo.png|thumb|left]]&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
Upstanding Lunatic&amp;lt;br&amp;gt;&lt;br /&gt;
Stationeers Community Contributor&amp;lt;br&amp;gt;&lt;br /&gt;
Author of [https://veterans-gaming.com/avcs AVCS profiles for VoiceAttack]&amp;lt;br&amp;gt;&lt;br /&gt;
Community Manager at [https://veterans-gaming.com Veterans-Gaming]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/@SemlerPDX SemlerPDX Stationeers Videos &amp;amp; Clips on YouTube]&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=User:SemlerPDX&amp;diff=23659</id>
		<title>User:SemlerPDX</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=User:SemlerPDX&amp;diff=23659"/>
		<updated>2025-10-06T19:23:37Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Pic and aboutme lines added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:SemlerPDX Logo.png|thumb|left]]&lt;br /&gt;
 &amp;lt;br&amp;gt;&lt;br /&gt;
Upstanding Lunatic&amp;lt;br&amp;gt;&lt;br /&gt;
Stationeers Community Contributor&amp;lt;br&amp;gt;&lt;br /&gt;
Author of [https://veterans-gaming.com/avcs AVCS profiles for VoiceAttack]&amp;lt;br&amp;gt;&lt;br /&gt;
Community Manager at [https://veterans-gaming.com Veterans-Gaming]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/playlist?list=PLCUtHj0YVK1-gts_RyTuRO944foi569D2 SemlerPDX Stationeers Videos &amp;amp; Clips on YouTube]&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=File:SemlerPDX_Logo.png&amp;diff=23658</id>
		<title>File:SemlerPDX Logo.png</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=File:SemlerPDX_Logo.png&amp;diff=23658"/>
		<updated>2025-10-06T19:19:12Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Avatar logo of SemlerPDX&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Solar_Logic_Circuits_Guide&amp;diff=23584</id>
		<title>Solar Logic Circuits Guide</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Solar_Logic_Circuits_Guide&amp;diff=23584"/>
		<updated>2025-09-25T21:22:07Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Adjusted wording and removed note discouraging new users to learn IC10&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]][[Category:Solar power]]&lt;br /&gt;
&amp;lt;languages /&amp;gt;&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
Due to the frequency of game updates, all solutions are subject to change and may or may not be functional.&lt;br /&gt;
&lt;br /&gt;
The designs on this page are valid as of v0.2.5906.26015 (2025-09-25)&lt;br /&gt;
&lt;br /&gt;
==Solar tracking using Logic Chips - Moon  ==&lt;br /&gt;
&lt;br /&gt;
Solar tracking on the [[Worlds|Moon]] is very minimal and straightforward due to its having a near 0° solar angle.  You will need the following:&lt;br /&gt;
&lt;br /&gt;
* x1 [[Sensors|Daylight Sensor]]&lt;br /&gt;
* x1 [[Logic I/O|Logic Reader]]&lt;br /&gt;
* x1 [[Logic I/O|Batch Writer]]&lt;br /&gt;
* [[Cables|Cable Coil]]s, a [[Wrench]], a [[Screwdriver]], and [[Wire Cutters]] at a minimum&lt;br /&gt;
&lt;br /&gt;
The orientation of the [[Sensors|Daylight Sensor]] is important for any solar logic control circuit.  Since we are only controlling the vertical alignment (0° solar angle negates the need for horizontal control), the direction of the data port does not matter; however, &#039;&#039;&#039;the blue solar face of the [[Sensors|Daylight Sensor]] must face either east or west&#039;&#039;&#039;.  You will have to manually adjust the angle of the horizontal angle on the [[Solar Panel]] with a [[Wrench]], dependent on the orientation you build the [[Solar Panel]], and whether the [[Sensors|Daylight Sensor]] faces east or west. Simply wait for the sun to be up and adjust until the panel is ~98% efficient.&lt;br /&gt;
&lt;br /&gt;
Hook up the logical components as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;Component&#039;&#039;&#039; !! &#039;&#039;&#039;Port A&#039;&#039;&#039; !! &#039;&#039;&#039;Connection A&#039;&#039;&#039; !! &#039;&#039;&#039;Port B&#039;&#039;&#039; !! &#039;&#039;&#039;Connection B&#039;&#039;&#039; !! &#039;&#039;&#039;Port C&#039;&#039;&#039; !! &#039;&#039;&#039;Connection C&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| [[Logic I/O|Logic Reader]] || IN || [[Sensors|Daylight Sensor]] || VAR || Vertical || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| [[Logic I/O|Batch Writer]] || IN || [[Logic I/O|Logic Reader]] || OUT VAR || Vertical || OUT TYPE || [[Solar Panel]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Solar tracking using Logic Chips - Non-Moon  ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;THE FOLLOWING INFORMATION NEEDS TESTING ON A NON-MOON PLANET., I (ERIZAMANU) DON&#039;T HAVE A WORKING NON-MOON SAVE (IM GOING FOR YEAR ACHIEVEMENT ON THE MOON RN) FOLLOWING THE TERRAIN UPDATE, SO IF SOMEONE COULD VERIFY THIS CIRCUIT OFF THE MOON AND DM ME I WOULD BE ETERNALLY GRATEFUL THANKS&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Solar tracking not on the [[Worlds|Moon]] remains straightforward, however is inherently more complicated due to not having a near 0° solar angle.  You will need the following:&lt;br /&gt;
&lt;br /&gt;
* x1 [[Sensors|Daylight Sensor]]&lt;br /&gt;
* x2 [[Logic I/O|Logic Reader]]&lt;br /&gt;
* x2 [[Logic I/O|Batch Writer]]&lt;br /&gt;
* [[Cables|Cable Coil]]s, a [[Wrench]], a [[Screwdriver]], and [[Wire Cutters]] at a minimum&lt;br /&gt;
* A [[Labeller]] is recommended to differentiate horizontal/vertical components, but not required&lt;br /&gt;
&lt;br /&gt;
The orientation of the [[Sensors|Daylight Sensor]] is important for any solar logic control circuit.  Since we are controlling both the vertical and horizontal alignments, &#039;&#039;&#039;the direction of the data port&#039;&#039;&#039; does matter, and &#039;&#039;&#039;must face either north or south&#039;&#039;&#039;. Additionally, &#039;&#039;&#039;the blue solar face of the [[Sensors|Daylight Sensor]] must face either east or west&#039;&#039;&#039;, and the &#039;&#039;&#039;[[Solar Panel]] power port must face east or west&#039;&#039;&#039;.  The pairing of the facings is as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! !! &#039;&#039;&#039;Blue Face / [[Solar Panel]] Power Port&#039;&#039;&#039; !! &#039;&#039;&#039;[[Sensors|Daylight Sensor]] Data Port&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Option 1 || West || South&lt;br /&gt;
|-&lt;br /&gt;
| Option 2 || East || North&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Hook up the logical components as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;Component&#039;&#039;&#039; !! &#039;&#039;&#039;Port A&#039;&#039;&#039; !! &#039;&#039;&#039;Connection A&#039;&#039;&#039; !! &#039;&#039;&#039;Port B&#039;&#039;&#039; !! &#039;&#039;&#039;Connection B&#039;&#039;&#039; !! &#039;&#039;&#039;Port C&#039;&#039;&#039; !! &#039;&#039;&#039;Connection C&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Vertical [[Logic I/O|Logic Reader]] || IN || [[Sensors|Daylight Sensor]] || VAR || Vertical || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| Vertical [[Logic I/O|Batch Writer]] || IN || Vertical [[Logic I/O|Logic Reader]] || OUT VAR || Vertical || OUT TYPE || [[Solar Panel]]&lt;br /&gt;
|-&lt;br /&gt;
| Horizontal [[Logic I/O|Logic Reader]] || IN || [[Sensors|Daylight Sensor]] || VAR || Horizontal || N/A || N/A&lt;br /&gt;
|-&lt;br /&gt;
| Horizontal [[Logic I/O|Batch Writer]] || IN || Horizontal [[Logic I/O|Logic Reader]] || OUT VAR || Horizontal || OUT TYPE || [[Solar Panel]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Solar tracking using IC-10 ==&lt;br /&gt;
&lt;br /&gt;
Using the in-game [[IC10]] code is a complicated process that requires learning and/or knowledge of programming in an assembly-level language similar to [https://en.wikipedia.org/wiki/MIPS_architecture MIPS], which IC10 was based upon/inspired by.  Even if you are not proficient at programming, given its simplistic nature, a solar tracking script is a great way to start learning [[IC10]], and the general logic and programming skills required to write even more complicated and advanced [[IC10]] code to automate your systems in Stationeers.&lt;br /&gt;
&lt;br /&gt;
If you are unable or prefer not to learn [[IC10]], you can find all sorts of prewritten [[IC10]] code such as [https://steamcommunity.com/sharedfiles/filedetails/?id=1892925984 Tallinu&#039;s IC10 Free-form Solar Tracking Script].&lt;br /&gt;
&lt;br /&gt;
== Geometry Of [[Solar Panel|Solar Panel]]s and [[Sensors|Daylight Sensors]] ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
daylight sensor horizontal.png|Geometry of horizontal values measured by daylight sensor&lt;br /&gt;
daylight sensor vertical.png|Geometry of vertical values measured by daylight sensor&lt;br /&gt;
solar panel yaw-Horizontal setting.png|Horizontal rotation of a solar panel&lt;br /&gt;
solar-horiz-formulas.svg|Equations relating horizontal sensor measurements from various orientations to solar panel horizontal rotation&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credits // Additonal Information ==&lt;br /&gt;
&lt;br /&gt;
The majority of this content is written by Erizamanu.  Feel free to DM me with &#039;&#039;&#039;constructive&#039;&#039;&#039; suggestions or questions via Discord.&lt;br /&gt;
&lt;br /&gt;
The previous page content was removed following an exchange on the Stationeers Discord between Fuddnir (Previous primary writer) and Risu.  The current circuit is an optimized (2 fewer components) version of Fuddnir&#039;s circuit that I developed for use in my game.&lt;br /&gt;
&lt;br /&gt;
See the Revision History under Actions for the full change logs.&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Sensors&amp;diff=23532</id>
		<title>Sensors</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Sensors&amp;diff=23532"/>
		<updated>2025-09-21T20:23:57Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Fixed power use of Daylight Sensor from 10W to 0W&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Solar power]]&lt;br /&gt;
&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;{{Itembox&lt;br /&gt;
 | name        = Kit (Sensors)&lt;br /&gt;
 | image       =  {{{image|[[File:ItemKitSensor.png]]}}}&lt;br /&gt;
 | stacks      = 5&lt;br /&gt;
 | constructs  = Daylight, Motion, Gas, Occupancy or Proximity Sensor&lt;br /&gt;
 | createdwith = [[Electronics Printer]]&lt;br /&gt;
 | cost        = 3g [[Iron]], 1g [[Gold]], 1g [[Copper]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Structurebox&lt;br /&gt;
 | name             = Daylight Sensor&lt;br /&gt;
 | prefab_hash      = 1076425094&lt;br /&gt;
 | prefab_name      = StructureDaylightSensor&lt;br /&gt;
 | power_usage      = 0W&lt;br /&gt;
 | image            = [[File:StructureDaylightSensor.png]]&lt;br /&gt;
 | placed_with_item = [[Kit (Sensors)]]&lt;br /&gt;
 | placed_on_grid   = Small Grid, On Frames&lt;br /&gt;
 | decon_with_tool1 = [[Hand Drill]]&lt;br /&gt;
 | item_rec1        = [[Kit (Sensors)]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Structurebox&lt;br /&gt;
 | name             = Motion Sensor&lt;br /&gt;
 | prefab_hash      = -1713470563&lt;br /&gt;
 | prefab_name      = StructureMotionSensor&lt;br /&gt;
 | power_usage      = 0W&lt;br /&gt;
 | image            = [[File:ItemMotionSensor.png]] &lt;br /&gt;
 | placed_with_item = [[Kit (Sensors)]]&lt;br /&gt;
 | placed_on_grid   = Small Grid, On Frames&lt;br /&gt;
 | decon_with_tool1 = [[Hand Drill]]&lt;br /&gt;
 | item_rec1        = [[Kit (Sensors)]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Structurebox&lt;br /&gt;
 | name             = Gas Sensor&lt;br /&gt;
 | prefab_hash      = -1252983604&lt;br /&gt;
 | prefab_name      = StructureGasSensor&lt;br /&gt;
 | power_usage      = 1W&lt;br /&gt;
 | image            = [[File:ItemGasSensor.png]] &lt;br /&gt;
 | placed_with_item = [[Kit (Sensors)]]&lt;br /&gt;
 | placed_on_grid   = Small Grid, On Frames&lt;br /&gt;
 | decon_with_tool1 = [[Hand Drill]]&lt;br /&gt;
 | item_rec1        = [[Kit (Sensors)]]&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
{{Structurebox&lt;br /&gt;
 | name             = Occupancy Sensor&lt;br /&gt;
 | prefab_hash      = 322782515&lt;br /&gt;
 | prefab_name      = StructureOccupancySensor&lt;br /&gt;
 | power_usage      = 0W&lt;br /&gt;
 | image            = [[File:StructureOccupancySensor.png]]&lt;br /&gt;
 | placed_with_item = [[Kit (Sensors)]]&lt;br /&gt;
 | placed_on_grid   = Small Grid, On Frames&lt;br /&gt;
 | decon_with_tool1 = [[Hand Drill]]&lt;br /&gt;
 | item_rec1        = [[Kit (Sensors)]]&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
{{Structurebox&lt;br /&gt;
 | name             = Proximity Sensor&lt;br /&gt;
 | prefab_hash      = 568800213&lt;br /&gt;
 | prefab_name      = StructureProximitySensor&lt;br /&gt;
 | power_usage      = 0W&lt;br /&gt;
 | image            = [[File:StructureProximitySensor.png]]&lt;br /&gt;
 | placed_with_item = [[Kit (Sensors)]]&lt;br /&gt;
 | placed_on_grid   = Small Grid, On Frames&lt;br /&gt;
 | decon_with_tool1 = [[Hand Drill]]&lt;br /&gt;
 | item_rec1        = [[Kit (Sensors)]]&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Description = &amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sensors are used to detect various parameters of their surroundings. &amp;lt;br/&amp;gt;&lt;br /&gt;
Only the [[Sensors#Daylight_Sensor|Daylight Sensor]] can be accessed directly by pointing at it. The other sensors require a [[Handheld Tablet]] with a [[Cartridge#Configuration|Configuration Cartridge]] to be accessed manually.&amp;lt;br/&amp;gt;&lt;br /&gt;
Their outputs can also be accessed using a [[Kit_(Logic_I/O)#Logic_Reader|Logic Reader]] or an [[Integrated Circuit (IC10)|Integrated Circuit]] inserted in an [[Kit (IC Housing)|IC Housing]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Daylight_sensor.jpg|In-game view of daylight sensor&lt;br /&gt;
File:Gas_sensor.jpg|In-game view of gas sensor&lt;br /&gt;
File:Motion_sensor.jpg|In-game view of motion sensor&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;big&amp;gt;Daylight Sensor&amp;lt;/big&amp;gt; = &amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The daylight sensor reports whether the sun hits the large grid the sensor is in, as well as the solar angle. Looking at the sensor will provide a tool-tip readout of this information, even when not connected to the network. The orientation of the daylight sensor is important, it will read different angle values depending on the orientation.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Daylight sensor horizontal.png|Horizontal parameter&lt;br /&gt;
File:Daylight sensor vertical.png|Vertical parameter&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
== Modes ==&lt;br /&gt;
{{warning|While the &amp;lt;kbd&amp;gt;Mode&amp;lt;/kbd&amp;gt; and &amp;lt;kbd&amp;gt;SolarAngle&amp;lt;/kbd&amp;gt; properties described below are still available, they are being deprecated in favor of &amp;lt;kbd&amp;gt;Horizontal&amp;lt;/kbd&amp;gt; and &amp;lt;kbd&amp;gt;Vertical&amp;lt;/kbd&amp;gt; data properties.&lt;br /&gt;
While &amp;lt;kbd&amp;gt;Vertical&amp;lt;/kbd&amp;gt; and &amp;lt;kbd&amp;gt;Vertical mode&amp;lt;/kbd&amp;gt; have the same value, &#039;&#039;&#039;&amp;lt;kbd&amp;gt;Horizontal&amp;lt;/kbd&amp;gt; and &amp;lt;kbd&amp;gt;Horizontal mode&amp;lt;/kbd&amp;gt; have opposite values&#039;&#039;&#039; (inverted sign).}} &lt;br /&gt;
The daylight sensor has a &amp;lt;kbd&amp;gt;Mode&amp;lt;/kbd&amp;gt; property which can be set with [[Kit_(Logic_I/O)#Logic_Writer|Logic Writer]] and  [[Kit_(Logic_Memory)|Memory chip]], or with an [[Integrated Circuit (IC10)|Integrated Circuit]]:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Default || The sensor will return the absolute value of the angle formed by the source of light and the normal vector of the sensor (towards which the grey/green part is facing). 0 means the source of light is facing to the sensor, 90 means it is aligned with the surface the sensor was laid on, and 180 means the source of light is in the back of the sensor. The angle is always a positive value between 0 and 180.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Horizontal || Returns the angle from the position of the source of light parallel to the surface of the sensor. The angle can be negative, ranging between -180 and +180.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Vertical || The sensor measures the angle from the position of the light source perpendicular to the surface of the sensor.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Daylight sensor horizontal mode.png|Values of SolarAngle in Horizontal mode&lt;br /&gt;
File:Daylight sensor vertical.png|Values of SolarAngle in Vertical mode&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
=== Examples ===&lt;br /&gt;
* If you lay a sensor on the ground, facing upwards, connector towards south,configured in horizontal mode, it will work like a compass with 0 = north, 90 = east, 180 = south and -90 = west&lt;br /&gt;
&lt;br /&gt;
* On the Moon/space : &amp;lt;br/&amp;gt; &#039;&#039;&#039;Note: these values are approximation and may vary slightly because of realistic orbital simulation&#039;&#039;&#039;&lt;br /&gt;
** If the daylight sensor is fixed on the floor, it will report 90 degrees at sunrise, up to 0 degrees at noon, back to 90 degrees at sunset, to 180 degrees at midnight, and back to 90 at sunrise.&lt;br /&gt;
** If fixed on a ceiling the cycle will be opposite, i.e.: 90 -&amp;gt; 180 -&amp;gt; 90 -&amp;gt; 0 -&amp;gt; 90.&lt;br /&gt;
** If fixed to an east facing wall, the cycle from sunrise is: 0 -&amp;gt; 90 -&amp;gt; 180 -&amp;gt; 90 -&amp;gt; 0.&lt;br /&gt;
** If fixed to a west facing wall, the cycle is opposite, i.e.: 180 -&amp;gt; 90 -&amp;gt; 0 -&amp;gt; 90 -&amp;gt; 180.&lt;br /&gt;
** If fixed to a north or south facing wall it will stay at 90 degrees all the time.&lt;br /&gt;
&lt;br /&gt;
== Solar tracking ==&lt;br /&gt;
&lt;br /&gt;
Tracking the sun using a Daylight Sensor allow [[Solar_Panel|Solar Panels]] to be more efficient by making them perpendicular to the light rays. &amp;lt;br/&amp;gt;&lt;br /&gt;
However, the orientation of the Daylight Sensor and Solar Panels must be taken into account and a [[Kit_(Logic_Processor)#Math_Unit|Math Unit]] may be required to correct the offset. &amp;lt;br/&amp;gt;&lt;br /&gt;
This [[Solar_Logic_Circuits_Guide|guide]] explains in detail how to set up a solar tracking circuit for solar panels.&lt;br /&gt;
&lt;br /&gt;
{{Data Network Header}}&lt;br /&gt;
{{Data Parameters|&lt;br /&gt;
{{Data Parameters/row|Mode|Integer|w=1|SolarAngle mode|multiple=3|0|Default|1|Horizontal|2|Vertical}}&lt;br /&gt;
{{Data Parameters/row|Activate|Boolean|w=1|1 if the device is running, 0 otherwise}}&lt;br /&gt;
{{Data Parameters/row|Horizontal|Float|w=1|Same absolute value &amp;lt;kbd&amp;gt;SolarAngle&amp;lt;/kbd&amp;gt; reported for &amp;lt;kbd&amp;gt;Horizontal&amp;lt;/kbd&amp;gt; mode but with an inverted sign}}&lt;br /&gt;
{{Data Parameters/row|Vertical|Float|w=1|Same as &amp;lt;kbd&amp;gt;SolarAngle&amp;lt;/kbd&amp;gt; reported for &amp;lt;kbd&amp;gt;Vertical&amp;lt;/kbd&amp;gt; mode}}&lt;br /&gt;
{{Data Parameters/row|SolarAngle|Float|w=0|See [[Sensors#Modes|Modes]] above. Probably soon deprecated in favor of &amp;lt;kbd&amp;gt;Horizontal&amp;lt;/kbd&amp;gt; and &amp;lt;kbd&amp;gt;Vertical&amp;lt;/kbd&amp;gt;}}&lt;br /&gt;
{{Data Parameters/row|On|Boolean|w=1|0 if Off, 1 if On}}&lt;br /&gt;
{{Data Parameters/row|PrefabHash|Integer|w=0|The hash of the structure}}&lt;br /&gt;
{{Data Parameters/row|SolarIrradiance|Float|w=0|The current solar irradiance (in W/m²)}}&lt;br /&gt;
{{Data Parameters/row|ReferenceId|Integer|w=0|Unique Reference Identifier for this object}}&lt;br /&gt;
{{Data Parameters/row|NameHash|Integer|w=0|Provides the hash value for the name of the object as a 32 bit integer}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;big&amp;gt;Motion Sensor&amp;lt;/big&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The motion sensor activates when a player or a non static object (such as a thrown item or a portable device) enters the large grid cube where the sensor is located, and deactivates when there are no more players or objects. Despite its name, the sensor will stay activated even if the entity does not move inside the cube.&amp;lt;br/&amp;gt;&lt;br /&gt;
This sensor can be useful to build systems that activate when the player is in a specific position (such as automatic doors for example). To check an entire room or area, see [[Sensors#Occupancy_Sensor|Occupancy Sensor]] and [[Sensors#Proximity_Sensor|Proximity Sensor]].&lt;br /&gt;
&lt;br /&gt;
{{Data Network Header}}&lt;br /&gt;
{{Data Parameters|&lt;br /&gt;
{{Data Parameters/row|Activate|Boolean|w=1|1 if an entity is detected, 0 otherwise. Even though the game consider it writable, trying to write this variable won&#039;t actually its value.}}&lt;br /&gt;
{{Data Parameters/row|Quantity|Integer|w=0|Number of detected entities}}&lt;br /&gt;
{{Data Parameters/row|On|Boolean|w=1|0 if Off, 1 if On (has no effect)}}&lt;br /&gt;
{{Data Parameters/row|PrefabHash|Integer|w=0|The hash of the structure}}&lt;br /&gt;
{{Data Parameters/row|ReferenceId|Integer|w=0|Unique Reference Identifier for this object}}&lt;br /&gt;
{{Data Parameters/row|NameHash|Integer|w=0|Provides the hash value for the name of the object as a 32 bit integer}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;big&amp;gt;Gas Sensor&amp;lt;/big&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The gas sensor will report information about the gas in the current atmosphere, such as pressure, temperature and gases ratio.&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;Note: Temperature is given in Kelvin, while your suit gives a readout in Celsius. To convert, use Celsius + 273.15 = Kelvin&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Data Network Header}}&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The gas sensor has no Input parameters, it&#039;s a read only device.&#039;&#039;&#039;&lt;br /&gt;
{{Data Parameters|&lt;br /&gt;
{{Data Parameters/row|Pressure|Float|w=0|In kPa}}&lt;br /&gt;
{{Data Parameters/row|Temperature|Float|w=0|In Kelvin}}&lt;br /&gt;
{{Data Parameters/row|Combustion|Boolean|w=0|1 if the atmosphere is on fire, 0 otherwise}}&lt;br /&gt;
{{Data Parameters/row|RatioOxygen|Float|w=0|Ratio of gaseous [[Oxygen]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioHydrogen|Float|w=0|Ratio of gaseous Hydrogen in the atmosphere (Hydrogen is deprecated and has been replaced by [[Volatiles]])}}&lt;br /&gt;
{{Data Parameters/row|RatioCarbonDioxide|Float|w=0|Ratio of gaseous [[Carbon Dioxide]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioNitrogen|Float|w=0|Ratio of gaseous [[Nitrogen]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioPollutant|Float|w=0|Ratio of gaseous [[Pollutant]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioVolatiles|Float|w=0|Ratio of gaseous [[Volatiles]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioNitrousOxide|Float|w=0|Ratio of gaseous [[Nitrous Oxide]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioSteam|Float|w=0|Ratio of gaseous [[Water]] in the atmosphere}}&lt;br /&gt;
&lt;br /&gt;
{{Data Parameters/row|RatioLiquidOxygen|Float|w=0|Ratio of liquid [[Oxygen]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidHydrogen|Float|w=0|Ratio of liquid Hydrogen in the atmosphere (Hydrogen is deprecated and has been replaced by [[Volatiles]])}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidCarbonDioxide|Float|w=0|Ratio of liquid [[Carbon Dioxide]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidNitrogen|Float|w=0|Ratio of liquid [[Nitrogen]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidPollutant|Float|w=0|Ratio of liquid [[Pollutant]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidVolatiles|Float|w=0|Ratio of liquid [[Volatiles]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioLiquidNitrousOxide|Float|w=0|Ratio of liquid [[Nitrous Oxide]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioWater|Float|w=0|Ratio of liquid [[Water]] in the atmosphere}}&lt;br /&gt;
{{Data Parameters/row|RatioPollutedWater|Float|w=0|Ratio of liquid [[Polluted Water]] in the atmosphere}}&lt;br /&gt;
&lt;br /&gt;
{{Data Parameters/row|PrefabHash|Integer|w=0|The hash of the structure}}&lt;br /&gt;
{{Data Parameters/row|ReferenceId|Integer|w=0|Unique Reference Identifier for this object}}&lt;br /&gt;
{{Data Parameters/row|NameHash|Integer|w=0|Provides the hash value for the name of the object as a 32 bit integer}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;big&amp;gt;Occupancy Sensor&amp;lt;/big&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The Occupancy Sensor detects the presence of a player when placed within a defined room. A defined room is when the game detects the space is entirely closed off from the rest of the world with walls, doors, etc. These do not need to be in the finished state to count as sealing a room.&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;Note: You can determine if a room is define by using the [[Cartridge#Atmos_Analyzer|Atmos Analyzer]] [[Cartridge]] with the [[Handheld_Tablet|tablet]]. If the top says &amp;quot;Room #&amp;quot; the room is sufficiently closed in.&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unlike to the [[Sensors#Motion_Sensor|Motion Sensor]], the Occupancy Sensor does not detect other entities such as thrown items or portable devices.&amp;lt;br/&amp;gt;&lt;br /&gt;
The Occupancy Sensor can be configured with a [[Cartridge#Atmos_Analyzer|Access Controller]] [[Cartridge]] in a [[Handheld_Tablet|tablet]] to only detect and report players equipped with a specific [[Access Card]].&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sensor can be great for systems that need to be activated when a player enters or leaves a room, such as lighting and other machines to preserve energy.&amp;lt;br/&amp;gt;&lt;br /&gt;
To detect players outside of a base or in a certain part of room only, the [[Sensor#Motion_Sensor|Motion Sensor]] and the [[Sensor#Proximity_Sensor|Proximity Sensor]] can be used.&lt;br /&gt;
&lt;br /&gt;
{{Data Network Header}}&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The occupancy sensor has no Input parameters, it&#039;s a read only device.&#039;&#039;&#039;&lt;br /&gt;
{{Data Parameters|&lt;br /&gt;
{{Data Parameters/row|Activate|Boolean|w=0|1 if a player is detected, 0 otherwise}}&lt;br /&gt;
{{Data Parameters/row|Quantity|Integer|w=0|Number of players detected}}&lt;br /&gt;
{{Data Parameters/row|PrefabHash|Integer|w=0|The hash of the structure}}&lt;br /&gt;
{{Data Parameters/row|ReferenceId|Integer|w=0|Unique Reference Identifier for this object}}&lt;br /&gt;
{{Data Parameters/row|NameHash|Integer|w=0|Provides the hash value for the name of the object as a 32 bit integer}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;big&amp;gt;Proximity Sensor&amp;lt;/big&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The Proximity Sensor will detect players inside a spherical zone with a radius set by the &amp;lt;code&amp;gt;Setting&amp;lt;/code&amp;gt; parameter. This value can be up to 250m and can be set using the dial on the sensor. &amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;Note: By pressing the Quantity Change key, you can increment by 10 instead of 1 when using the dial.&#039;&#039;&amp;lt;br/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Like the [[Sensors#Occupancy_Sensor|Occupancy Sensor]], the Proximity Sensor can be configured with a [[Cartridge#Atmos_Analyzer|Access Controller]] [[Cartridge]] in a [[Handheld_Tablet|tablet]] to only detect and report players equipped with a specific [[Access Card]].&amp;lt;br/&amp;gt;&lt;br /&gt;
Unlike to the [[Sensors#Motion_Sensor|Motion Sensor]], the Proximity Sensor does not detect other entities such as thrown items or portable devices.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Data Network Header}}&amp;lt;br/&amp;gt;&lt;br /&gt;
{{Data Parameters|&lt;br /&gt;
{{Data Parameters/row|Activate|Boolean|w=0|1 if a player is detected, 0 otherwise}}&lt;br /&gt;
{{Data Parameters/row|Setting|Float|w=1|Range of the sensor in meter (0 to 250}}&lt;br /&gt;
{{Data Parameters/row|Quantity|Integer|w=0|Number of players detected}}&lt;br /&gt;
{{Data Parameters/row|PrefabHash|Integer|w=0|The hash of the structure}}&lt;br /&gt;
{{Data Parameters/row|ReferenceId|Integer|w=0|Unique Reference Identifier for this object}}&lt;br /&gt;
{{Data Parameters/row|NameHash|Integer|w=0|Provides the hash value for the name of the object as a 32 bit integer}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=23519</id>
		<title>File:Filter system BASIC.png</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=23519"/>
		<updated>2025-09-21T06:42:55Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: SemlerPDX uploaded a new version of File:Filter system BASIC.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A more simplified basic filtration layout for scrubbing air in a base.&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Air_Filtration_System&amp;diff=23518</id>
		<title>Air Filtration System</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Air_Filtration_System&amp;diff=23518"/>
		<updated>2025-09-21T06:39:18Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Removed pointless one-way valve&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Tutorials]]&lt;br /&gt;
&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
This is an air filtration system that will scrub all bad gases from the air, place them in a tank and cool down the air at the same time.  A second simplified system is listed below, which merely vents any gas not matching base air back to the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
[[File:Filter system.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
=== Filter System (Dual) Items Used === &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* [[Active Vent]]&lt;br /&gt;
* [[Atmospherics|Atmospherics(Filtration)]] &lt;br /&gt;
* [[Filter|Filters (CO2, Pollutant, Volatiles)]]&lt;br /&gt;
* [[Passive Vent]]&lt;br /&gt;
* [[Pipes]]&lt;br /&gt;
* [[Pipe Meter]]&lt;br /&gt;
* [[Pipe Radiator]]&lt;br /&gt;
* [[Pipe Volume Pump]]&lt;br /&gt;
* [[Tank]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
This is a more basic simplified air filtration system, which merely vents any gas not matching base air (Oxygen/Nitrogen) back to the world atmosphere.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
[[File:Filter system BASIC.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
=== Filter System (Basic) Items Used === &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* [[Active Vent]]&lt;br /&gt;
* [[Atmospherics|Atmospherics(Filtration)]] &lt;br /&gt;
* [[Filter|Filters (Oxygen, Nitrogen)]]&lt;br /&gt;
* [[Passive Vent]]&lt;br /&gt;
* [[Pipes]]&lt;br /&gt;
* [[Pipe Volume Pump]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=23517</id>
		<title>File:Filter system BASIC.png</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=23517"/>
		<updated>2025-09-21T06:38:30Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: SemlerPDX uploaded a new version of File:Filter system BASIC.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A more simplified basic filtration layout for scrubbing air in a base.&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=IC10&amp;diff=22951</id>
		<title>IC10</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=IC10&amp;diff=22951"/>
		<updated>2025-08-06T20:26:59Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Moved the IC10 Schmitt Trigger example I added below the Solar Panel Tracking example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:IC10 Programming]]&lt;br /&gt;
=Scripting language for IC10 housings / chips=&lt;br /&gt;
MIPS is [[Stationeers]]&#039; inspiration for the in-game scripting language called IC10. It runs on [[Integrated Circuit (IC10)|IC10 chips]] crafted at the [[Electronics Printer]]. &lt;br /&gt;
&lt;br /&gt;
==Registers==&lt;br /&gt;
Internal registers &#039;&#039;&#039;r?&#039;&#039;&#039;: The IC contains 16 CPU registers, numbered &#039;&#039;&#039;r0&#039;&#039;&#039; to &#039;&#039;&#039;r15&#039;&#039;&#039;. From now on referred to as &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Device registers &#039;&#039;&#039;d? logicType&#039;&#039;&#039;: Device registers are written to and from the IC. A device register is numbered &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039; (select via screw), or &#039;&#039;&#039;db&#039;&#039;&#039; (connected device). From now on referred to as &#039;&#039;&#039;d?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Logic and algorithmic with &#039;&#039;&#039;Internal registers&#039;&#039;&#039; ===&lt;br /&gt;
All calculations are exclusively performed to and from &#039;&#039;&#039;r?&#039;&#039;&#039; registers, or generally more understood as variables in programming. You can use aliases to give convenient names with the &amp;lt;code&amp;gt;alias string r?|d?&amp;lt;/code&amp;gt;command (see below). &lt;br /&gt;
&lt;br /&gt;
Internal registers can be manipulated in various ways. &lt;br /&gt;
* Write constant values &amp;lt;code&amp;gt;move r? (r?|num)&amp;lt;/code&amp;gt;: Example: &amp;lt;code&amp;gt;move r0 2&amp;lt;/code&amp;gt; sets r0 to the number 2.&lt;br /&gt;
* Calculate: Calculations are done to- and from these registers, like &amp;lt;code&amp;gt;add r? a(r?|num) b(r?|num)&amp;lt;/code&amp;gt;. Example: &amp;lt;code&amp;gt;add r1 r0 3&amp;lt;/code&amp;gt; adds 3 to r0, and writes to r1.&lt;br /&gt;
&lt;br /&gt;
Note, for any kind of if statements or loop behaviours, knowing about labels, branching, and jumps is essential knowledge. See below.&lt;br /&gt;
&lt;br /&gt;
=== IO to &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
Acronym &#039;&#039;&#039;d?&#039;&#039;&#039; stands for device, where ? is a number corresponding to the screw device selector on the socket.&lt;br /&gt;
You can also read/write to the device where the IC is planted in using device &#039;&#039;&#039;db&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Generally, there are up to 6 devices which can be set using the screwdriver &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039;. A special device register &#039;&#039;&#039;db&#039;&#039;&#039; is the device wherever the IC is mounted upon. Very convenient for atmospheric devices where no separate IC socket is required.&lt;br /&gt;
&lt;br /&gt;
Note, the IC is completely unaware where d? is actually connected to. So if you get a logicType error, check d? number, or check if the screw has been set on the socket. An alias is only convenient to convey what is expected to be set on the d? screw, it does not actually set or program the screw.&lt;br /&gt;
&lt;br /&gt;
* Read from device (load) &amp;lt;code&amp;gt;l r? d? logicType&amp;lt;/code&amp;gt;: Reads logicType, like Pressure from a [[Sensors|gas sensor]], from device d? to register r?. Values can be read from connected devices and put into the register using the &#039;&#039;&#039;l&#039;&#039;&#039; (load) command. For example, if you want to load the state of a door. &amp;lt;br&amp;gt; Example: &amp;lt;code&amp;gt;l r0 Door Open&amp;lt;/code&amp;gt; reads the &#039;Open&#039; field of an object named &#039;Door&#039;, that would be connected to the IC housing of the chip.&lt;br /&gt;
* Write to a device (set) &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;: Write a value from a register back to a device using the command &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;. For example, if d0 is set to a door using the screwdriver, &amp;lt;code&amp;gt;s d0 Open 0&amp;lt;/code&amp;gt; sets the &#039;Open&#039; status of the d0 (a door) to 0, effectively closing the door.&lt;br /&gt;
&lt;br /&gt;
=== batch IO to - &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
&#039;&#039;&#039;Batch writing&#039;&#039;&#039; needs to be done to a specific &#039;&#039;&#039;deviceHash&#039;&#039;&#039; instead of d?. Is unique per device type, which you can find in the [[Stationpedia]] entries.&lt;br /&gt;
* &amp;lt;code&amp;gt;lb r? deviceHash logicType batchMode&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt;sb deviceHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
Additionally, using the following batch commands, a &#039;&#039;&#039;nameHash&#039;&#039;&#039; can be provided to only modify devices with a certain name.&lt;br /&gt;
* &amp;lt;code&amp;gt;lbn r? deviceHash nameHash logicType batchMode &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sbn deviceHash nameHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All hashes used in the game are CRC-32 checksums computed from the strings they represent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;batchMode&#039;&#039;&#039; is a parameter equal to 0, 1, 2, or 3. These are also defined as the constants &#039;&#039;&#039;Average&#039;&#039;&#039;, &#039;&#039;&#039;Sum&#039;&#039;&#039;, &#039;&#039;&#039;Minimum&#039;&#039;&#039;, and &#039;&#039;&#039;Maximum&#039;&#039;&#039; respectively. The word or number can be used.&lt;br /&gt;
&lt;br /&gt;
Combining one of these functions with the &amp;lt;code&amp;gt;HASH()&amp;lt;/code&amp;gt; function can be advantageous:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbn r0 HASH(&amp;quot;StructureGasSensor&amp;quot;) HASH(&amp;quot;Sensor 1&amp;quot;) Temperature Average&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will load the average temperature of all gas sensors on the network named &amp;quot;Sensor 1&amp;quot; onto register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the batch read (lb/lbn) is done on a network without any matching devices the results will be as specified in the table:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Batch read with no devices&lt;br /&gt;
|-&lt;br /&gt;
! Batch Mode !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Average (0) || nan&lt;br /&gt;
|-&lt;br /&gt;
| Sum (1) || 0&lt;br /&gt;
|-&lt;br /&gt;
| Minimum (2) || inf&lt;br /&gt;
|-&lt;br /&gt;
| Maximum (3) || ninf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
Here are some examples demonstrating all three operations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 10&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Sets register &#039;&#039;&#039;r0&#039;&#039;&#039; to the value 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Copies the value of register &#039;&#039;&#039;r1&#039;&#039;&#039; to register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;l r0 d0 Temperature&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Reads the Temperature parameter from device &#039;&#039;&#039;d0&#039;&#039;&#039; and places the value in register &#039;&#039;&#039;r0&#039;&#039;&#039;.&lt;br /&gt;
Note: not all devices have a Temperature parameter, check the in-game stationpedia.&lt;br /&gt;
&lt;br /&gt;
To set a device specific value (like &#039;&#039;&#039;On&#039;&#039;&#039;), you can write into this value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;s d0 On r0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Writes the value from register &#039;&#039;&#039;r0&#039;&#039;&#039; out to &#039;&#039;&#039;On&#039;&#039;&#039; parameter of device &#039;&#039;&#039;d0&#039;&#039;&#039;. In this example the device will be turned On, if valve of register r0 equals 1, otherwise (register r0 equals 0) it will turned off. See section [[IC10#Device_Variables|Device Variables]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s recommended to use labels (like: &#039;&#039;someVariable&#039;&#039;) instead of a direct reference to the register. See &#039;&#039;&#039;alias&#039;&#039;&#039; in section [[IC10#Instructions|Instructions]].&lt;br /&gt;
&lt;br /&gt;
=== Special registers ===&lt;br /&gt;
There are two more registers. One called &#039;&#039;&#039;ra&#039;&#039;&#039; (return address) and one called &#039;&#039;&#039;sp&#039;&#039;&#039; (stack pointer). The &#039;&#039;&#039;ra&#039;&#039;&#039; is used by certain jump and branching instructions (those ending with &#039;&#039;&#039;-al&#039;&#039;&#039;) to remember which line in the script it should return to. The &#039;&#039;&#039;sp&#039;&#039;&#039; tracks the next index within the stack (a memory that can store up to 512 values) to be pushed (written) to or popped (read) from. Neither &#039;&#039;&#039;ra&#039;&#039;&#039; or &#039;&#039;&#039;sp&#039;&#039;&#039; is protected, their values can be changed by instructions like any other register.&lt;br /&gt;
&lt;br /&gt;
==Stack Memory==&lt;br /&gt;
The Stack is a memory that can hold 512 different values. Each IC10 has its own Stack, and some devices (like the Logical Sorter) also have a Stack.&lt;br /&gt;
;push r?: adds the value  &#039;&#039;&#039;r?&#039;&#039;&#039; and increments the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;pop r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039; and decrements the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;peek r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;get r? d? address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;getd r? id(r?|num) address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device id into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;put d? address(r?|num) value(r?|num): adds the value to the stack memory off the provided device at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
;putd id(r?|num) address(r?|num) value(r?|num) : adds the value to the stack memory off the provided device id at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, &#039;&#039;&#039;sp&#039;&#039;&#039; can be both written to and read from any time. When reading (&#039;&#039;&#039;peek&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 1 and 512, inclusive. While writing (&#039;&#039;&#039;push&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 0 and 511, inclusive.&lt;br /&gt;
&lt;br /&gt;
Stack memory is persistent on logic chips. This means that if you have a logic chip and push values to the stack, the code that pushes those values can be removed and the stack will retain those values.&lt;br /&gt;
&lt;br /&gt;
Note that this does not carry over to any other logic chips which receive the program of the original; They will need to have their stack memories programmed individually.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stack Traversing&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Traversing the stack can be done similarly to how an array would be traversed in some other languages:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#this will traverse indices {min value} through {max value}-1&lt;br /&gt;
move sp {min value}&lt;br /&gt;
loop:&lt;br /&gt;
add sp sp 1&lt;br /&gt;
peek r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
blt sp {max value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the pop function&#039;s decrementing to make a more efficient loop:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move sp {max value}&lt;br /&gt;
add sp sp 1&lt;br /&gt;
loop:&lt;br /&gt;
pop r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
bgt sp {min value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments can be placed using a &#039;&#039;&#039;#&#039;&#039;&#039; symbol. All comments are ignored by the game when it reads commands. Below is an example of valid code with two comments.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias MyAlias r0 # Text after the hash tag will be ignored to the end of the line.&lt;br /&gt;
# You can also write comments on their own lines, like this.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Device Ports==&lt;br /&gt;
ICs can interact with up to 6 other devices via d0 - d5, as well as the device it&#039;s attached to via db. To change or set a device, use a screwdriver and adjust the device in the IC housing. You can read or set any of the device&#039;s properties, so it is possible to do things like read the pressure or oxygen content of a room on the same Device port. &lt;br /&gt;
&lt;br /&gt;
Additionally, is possible to set other IC housings as devices, allowing you to create programs that run across multiple ICs together. For example, an Gas Mixing IC could check the &#039;&#039;&#039; Setting&#039;&#039;&#039;  field of a Atmosphere Sensor IC and act based on the value of the sensor chip.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;l&#039;&#039;&#039; (load) or &#039;&#039;&#039;s&#039;&#039;&#039; (set) instructions you have to read or set these values to your device. Examples:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#Reads the &#039;Temperature&#039; from an atmosphere sensor&lt;br /&gt;
# at device port &#039;d0&#039; into register &#039;r0&#039;.&lt;br /&gt;
l r0 d0 Temperature&lt;br /&gt;
}} &lt;br /&gt;
{{ICCode|&lt;br /&gt;
# Writes the value of the register &#039;r0&#039; to the&lt;br /&gt;
# device on port &#039;d1&#039; into the variable &#039;Setting&#039;.&lt;br /&gt;
s d1 Setting r0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are used to make it easier to jump between lines in the script. The label will have a numerical value that is the same as its line number. Even though it&#039;s possible to use a labels value for calculations, doing so is a bad idea since any changes to the code can change the line numbers of the labels.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
main: # define a jump mark with label &#039;main&#039;&lt;br /&gt;
j main # jumps back to &#039;main&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
Instead of using a register to store a fixed value, a constant can be made. Using this name will refer to the assigned value. With the help of Constants you can save register places.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# defines a Constant with name &#039;pi&#039;&lt;br /&gt;
# and set its value to 3.14159&lt;br /&gt;
define pi 3.14159&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
You can use these constants like any other variables (see: alias in section [[IC10#Instructions|Instructions]]). Example:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# set the value of register &#039;r0&#039; to the value of constant named &#039;pi&#039;.&lt;br /&gt;
move r0 pi &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Numeric values==&lt;br /&gt;
Registers and constants are usually decimal values using double-precision floating point (confirmed?).&lt;br /&gt;
&lt;br /&gt;
Unlike real CPU architectures, integers are not supported as a distinct type, but double FP can represent integers up to about 54 bits before rounding causes problems (the exact number depending what bit patterns you happen to have).&lt;br /&gt;
&lt;br /&gt;
Numbers can be written in hexadecimal by preceding the value with a $ symbol. Values larger than 54 bits might get corrupted. Hex numbers are typically used for ReferenceId values.&lt;br /&gt;
&lt;br /&gt;
Examples: &lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 12345&lt;br /&gt;
move r1 123.456&lt;br /&gt;
move r2 $E1B2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Indirect referencing==&lt;br /&gt;
This is a way of accessing a register by using another register as a pointer. Adding an additional r in front of the register turns on this behaviour. The value stored in the register being used as the pointer must be between 0 to 15, this will then point to a register from r0 to r15, higher or lower values will cause an error.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 5 # stores the value 5 in r0&lt;br /&gt;
move rr0 10 &lt;br /&gt;
# is now the same as &#039;move r5 10&#039; &lt;br /&gt;
# since r0 has the value 5, rr0 points at the register r5&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Additional r&#039;s can be added to do indirect referencing multiple times in a row.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r1 2&lt;br /&gt;
move r2 3&lt;br /&gt;
move rrr1 4&lt;br /&gt;
# is now the same as &#039;move r3 4&#039;&lt;br /&gt;
# since r1 points at r2 which points at r3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This also works with devices&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 2 # stores the value 2 in r0&lt;br /&gt;
s dr0 On 1 &lt;br /&gt;
# is now the same as &#039;s d2 On 1&#039;&lt;br /&gt;
# r0 has the value 2 so dr0 points at d2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Dynamically changing LogicType when interacting with Device Registers ==&lt;br /&gt;
When the &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; instructions are used to read from or write to a Device Register, the LogicType is the variable that will be interacted with (example: in &amp;lt;code&amp;gt;l r0 myDevice Temperature&amp;lt;/code&amp;gt; the LogicType is the Temperature). In most scripts the LogicType will be hardcoded. But it&#039;s also possible to change the LogicType dynamically. The LogicType is an enum, where each type is identified by a unique integer value. This makes it possible to cycle through them in various ways, either as a list placed on the Stack, or by increasing the LogicType value via addition in each loop.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#loop through a list of LogicTypes&lt;br /&gt;
push LogicType.RatioOxygen&lt;br /&gt;
push LogicType.RatioVolatiles&lt;br /&gt;
push LogicType.Temperature&lt;br /&gt;
loop:&lt;br /&gt;
pop r1&lt;br /&gt;
l r0 myDevice r1&lt;br /&gt;
...&lt;br /&gt;
bgtz sp loop #loop until the Stack is empty}}&lt;br /&gt;
&lt;br /&gt;
==Network Referencing / Channels==&lt;br /&gt;
&lt;br /&gt;
All cable networks have 8 Channels which can have data loaded from/stored to via a device and connection reference. Connections for each supported device are listed in the stationpedia. All &#039;connections&#039; a device can make are a connection (pipe, chute, cable), but only cable networks have channels.&lt;br /&gt;
&lt;br /&gt;
The 8 channels (Channel0 to Channel7) are however volatile, in that data is destroyed if any part of the cable network is changed, removed, or added to, and also whenever the world is exited. All these channels default to NaN. Strictly speaking, they default to what we would call &amp;quot;quiet NaN&amp;quot;, in that its not an error it simply means its not a number yet. Recommend you use these channels for reading and writing between networks, rather than as a data store. This effectively means an IC can read all the networks for all devices to connected to it, so not just their own local network, but any networks any device they can reference is connected to.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# d0 is device zero, and the :0 refers&lt;br /&gt;
# to that device&#039;s 0 connection&lt;br /&gt;
l r0 d0:0 Channel0}}&lt;br /&gt;
&lt;br /&gt;
For example: on an IC Housing, the 0 connection is the data port and 1 is power, so you could write out r0 to Channel0 of the power network of the Housing using &amp;lt;code&amp;gt;s db:1 Channel0 r0&amp;lt;/code&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#read all 8 channels with a loop and&lt;br /&gt;
#place the values in r0 to r7&lt;br /&gt;
move r15 LogicType.Channel0 #LogicType integer&lt;br /&gt;
move r14 0 #pointer for indirect referencing&lt;br /&gt;
loop:&lt;br /&gt;
l rr14 db:0 r15&lt;br /&gt;
add r15 r15 1 #next channel&lt;br /&gt;
add r14 r14 1 #next register&lt;br /&gt;
ble r15 LogicType.Channel7 loop&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Logic gates, Bitwise and Logical==&lt;br /&gt;
&lt;br /&gt;
All logic gates in MIPS have a bitwise behavior. The available gates are NOT, AND, OR, XOR and NOR (XNOR and NAND are missing).&lt;br /&gt;
&lt;br /&gt;
In Bitwise operations, each bit is matched separately, which includes the sign bit.&lt;br /&gt;
&lt;br /&gt;
To understand what is going on with bitwise operations, a little bit of computer theory is needed. In Stationeers each register uses 64 bits for integer values (a number without decimals), where the 64th bit is the sign-bit (0 for positive and 1 for negative). Since the number 0 is counted as a positive value, this gives each register a range of (2^63 - 1) to -2^63. Negative numbers also behave according to Two&#039;s complement (https://en.wikipedia.org/wiki/Two%27s_complement). Which means that a number with a sign-bit of 1 will have all of its number bits flipped as well, so that the decimal value of -1 is represented by a binary value of sixtyfour 1&#039;s (this is the smallest possible negative integer since zero counts as a positive integer).&lt;br /&gt;
&lt;br /&gt;
MIPS have binary notation (https://en.wikipedia.org/wiki/Binary_number) that is activated by placing a % in front of the number. The _ characters are ignored and only used for readability.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;not r0 0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 0 = %00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# flip all bits&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# -1 = %11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals -1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;and r0 3 6&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 3 = %011&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 6 = %110&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# only the bits in the &amp;quot;2&amp;quot; position are matching&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals %010 = 2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operations can still be performed via alternative instructions. But these are not perfect substitutes, they treat negative values differently, and some can produce non-binary outputs. When using these, keep in mind that devices that wants a binary value will treat any non-binary values like this: &amp;gt;= 1 counts as &amp;quot;1&amp;quot; and &amp;lt;1 counts as &amp;quot;0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 = result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r1 = input A&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r2 = input B&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOT = seqz r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical AND = min r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical OR = max r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XOR = sne r0 r1 r2 (only for binary inputs)&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NAND = not and&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOR = not or&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XNOR = not xor&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging advices==&lt;br /&gt;
The value stored in a register or variable can easily be displayed by writing it to the Setting parameter of the IC housing. This has no side effects. To see the value, just stand close to the IC housing and look directly at the housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting r0&amp;lt;/code&amp;gt;. # sets/writes the value of register &#039;&#039;&#039;r0&#039;&#039;&#039; into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
To check if a certain block of code is executed, use the above trick but with a random number that you choose, like the line number.&amp;lt;br&amp;gt; This example will display the number 137 on the IC housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting 137&amp;lt;/code&amp;gt;  # sets/writes the number 137 into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Always use unique names for labels. When a label is named after a IC10 keyword like &amp;quot;Temperature:&amp;quot; or &amp;quot;Setting:&amp;quot; the original meaning of the keyword is overwritten, so when an instruction tries to use it an error will occur.&lt;br /&gt;
&lt;br /&gt;
A [[Cartridge#Configuration|configuration cartridge]] installed in a [[Handheld_Tablet|tablet]]  can be used to see all available values and configuration parameter for all devices you focus on.&lt;br /&gt;
&lt;br /&gt;
==Learning IC10==&lt;br /&gt;
IC10 can be difficult to get started with. So here is a list of instructions that are useful for beginners. These can be used to write many different scripts.&lt;br /&gt;
&lt;br /&gt;
General:&lt;br /&gt;
* &amp;lt;code&amp;gt;alias&amp;lt;/code&amp;gt; make the script easier to read by assigning a name to a register or device, example: &amp;lt;code&amp;gt;alias rTemperature r15&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;label:&amp;lt;/code&amp;gt; where &amp;quot;label&amp;quot; can be replaced with almost any word, jump and branch instructions can use these in place of line numbers, example: &amp;lt;code&amp;gt;start:&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; pause for 1-tick and then resume, if not used the script will automatically pause for 1-tick after 128 lines&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Jumps:&lt;br /&gt;
*&amp;lt;code&amp;gt;j someLabelName&amp;lt;/code&amp;gt; jump to line with &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;jal someLabelName&amp;lt;/code&amp;gt; stores the next line number into the register ra (return address) and then jump to &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt; jump to register ra (return address)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Branching (jump-if):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;beq a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if &#039;&#039;&#039;a&#039;&#039;&#039; is equal to &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039;  (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bne a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; not-equal &#039;&#039;&#039;b&#039;&#039;&#039; goto  &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bgt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; greater than &#039;&#039;&#039;b&#039;&#039;&#039; goto   &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;blt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; less than &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
The suffix -al can be added to each of these (example: beqal) to save the &#039;&#039;&#039;next&#039;&#039;&#039; line number into the &amp;quot;return address&amp;quot; register. this is called using &amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Device interactions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
l (load)&lt;br /&gt;
lb (load batch, requires one of the following: 0(Average) / 1(Sum) / 2(Minimum) / 3(Maximum))&lt;br /&gt;
ls (load slot)&lt;br /&gt;
s (store)&lt;br /&gt;
sb (store batch)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Logic and Math:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seqz (common NOT-gate: turns 0 into 1, and all other values into 0)&lt;br /&gt;
move&lt;br /&gt;
add (addition)&lt;br /&gt;
sub (subtraction)&lt;br /&gt;
mul (multiplication)&lt;br /&gt;
div (division)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Common device variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On (1 is on, 0 is off)&lt;br /&gt;
Open (1 is open, 0 is closed)&lt;br /&gt;
Setting (meaning varies between devices, example: a LED display(console) will show this value)&lt;br /&gt;
Activate (1 usually means running, example: a Daylight sensor is 1 when the sun shines on it)&lt;br /&gt;
Temperature (in Kelvin, Celsius - 273.15)&lt;br /&gt;
Pressure (in kPa)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Notes:&lt;br /&gt;
&amp;lt;br&amp;gt;-All instructions and variables can be seen in-game in the IC editor window by clicking the &amp;quot;f&amp;quot;, &amp;quot;x&amp;quot; and &amp;quot;s(x)&amp;quot; buttons on the top right.&lt;br /&gt;
&amp;lt;br&amp;gt;-The stationpedia is the best source to see which variables are available to each device.&lt;br /&gt;
&amp;lt;br&amp;gt;-Most scripts are loops, they end with a jump instruction that leads back up to the start. Otherwise they will just run once and then stop.&lt;br /&gt;
&lt;br /&gt;
Two practice scripts:&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Night Light: Load &amp;quot;Activate&amp;quot; from a Daylight sensor, flip the value with a NOT-gate, store the value to the &amp;quot;On&amp;quot; variable of one or more lights.&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Wall Cooler: Read &amp;quot;Temperature&amp;quot; from a Gas Sensor. Branch if the value is greater than X, turn on the cooler. Branch if the value is less than Y, turn off the cooler. (Wall coolers need a minimum of 12.5 kPa pressure in the connected pipe)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Accessing devices via batch or ReferenceId ==&lt;br /&gt;
&lt;br /&gt;
The IC housing has 6 pins you can use to configure the devices it&lt;br /&gt;
uses.  This provides flexibility to let the installer configure which&lt;br /&gt;
devices will be controlled by the IC.&lt;br /&gt;
&lt;br /&gt;
Alternatives for accessing devices include the batch load/store and&lt;br /&gt;
the ReferenceId load/store instructions.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the average charge ratio across station batteries&lt;br /&gt;
lb r0 HASH(&amp;quot;StructureBattery&amp;quot;) Ratio Average&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the ReferenceId for the sorter named &amp;quot;Sorter Corn&amp;quot;&lt;br /&gt;
lbn r1 HASH(&amp;quot;StructureLogicSorter&amp;quot;) HASH(&amp;quot;Sorter Corn&amp;quot;) ReferenceId Maximum&lt;br /&gt;
ble r1 ninf ra&lt;br /&gt;
#use the ReferenceId to set that sorter&#039;s mode.&lt;br /&gt;
sd r1 Mode 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Using the 6 configuration pins makes it easy to write reusable MIPS&lt;br /&gt;
scripts where the installer uses the pins to select the devices that&lt;br /&gt;
will be managed.&lt;br /&gt;
&lt;br /&gt;
Using batch-name instructions frees you from the hassle of adjusting&lt;br /&gt;
the pins, but requires you to name the devices via the [[Labeller]].  It&lt;br /&gt;
can also allow you to control more than 6 devices.&lt;br /&gt;
&lt;br /&gt;
=== Batch instructions ===&lt;br /&gt;
&lt;br /&gt;
The batch instructions can address multiple devices only via their &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; generated from the prefab name using the `HASH(&amp;quot;Name&amp;quot;)` macro or copied directly from the [[Stationpedia]]. A prefab hash is always an integer. All devices that can be read with logic contain the logic value &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; and &#039;&#039;&#039;NameHash&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
See [[#Slot.2FLogic_.2F_Batched|Batched instructions]] for a comprehensive list of all batch instructions.&lt;br /&gt;
&lt;br /&gt;
[[#sb|sb]], [[#sbn|sbn]], [[#sbs|sbs]], (no sbns)&amp;lt;br&amp;gt;&lt;br /&gt;
[[#lb|lb]], [[#lbs|lbs]], [[#lbn|lbn]], [[#lbns|lbns]]&lt;br /&gt;
&lt;br /&gt;
=== Direct reference instructions ===&lt;br /&gt;
&lt;br /&gt;
Direct reference instructions can address a specific device via its &#039;&#039;&#039;ReferenceId&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[#clrd|clrd]], [[#getd|getd]], [[#putd|putd]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[#ld|ld]], [[#sd|sd]], (no slot access via reference ID)&lt;br /&gt;
&lt;br /&gt;
=Instructions=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
See [[IC10/instructions]]&lt;br /&gt;
&lt;br /&gt;
{{:IC10/instructions}}&lt;br /&gt;
&lt;br /&gt;
[https://www.cs.tufts.edu/comp/140/lectures/Day_3/mips_summary.pdf Other examples]&lt;br /&gt;
&lt;br /&gt;
== Conditional functions cheatsheet ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! suffix !! description !! branch to line !! branch and store return address !! relative jump to line !! set register&lt;br /&gt;
|-&lt;br /&gt;
| prefix: ||  || b- || b-al || br- || s-&lt;br /&gt;
|-&lt;br /&gt;
|  || unconditional || j    || jal    || jr    || &lt;br /&gt;
|-&lt;br /&gt;
| -eq  || if a == b || beq  || beqal  || breq  || seq&lt;br /&gt;
|-&lt;br /&gt;
| -eqz || if a == 0 || beqz || beqzal || breqz || seqz&lt;br /&gt;
|-&lt;br /&gt;
| -ge  || if a &amp;gt;= b || bge  || bgeal  || brge  || sge&lt;br /&gt;
|-&lt;br /&gt;
| -gez || if a &amp;gt;= 0 || bgez || bgezal || brgez || sgez&lt;br /&gt;
|-&lt;br /&gt;
| -gt  || if a &amp;gt; b  || bgt  || bgtal  || brgt  || sgt&lt;br /&gt;
|-&lt;br /&gt;
| -gtz || if a &amp;gt; 0  || bgtz || bgtzal || brgtz || sgtz&lt;br /&gt;
|-&lt;br /&gt;
| -le  || if a &amp;lt;= b || ble  || bleal  || brle  || sle&lt;br /&gt;
|-&lt;br /&gt;
| -lez || if a &amp;lt;= 0 || blez || blezal || brlez || slez&lt;br /&gt;
|-&lt;br /&gt;
| -lt  || if a &amp;lt; b  || blt  || bltal  || brlt  || slt&lt;br /&gt;
|-&lt;br /&gt;
| -ltz || if a &amp;lt; 0  || bltz || bltzal || brltz || sltz&lt;br /&gt;
|-&lt;br /&gt;
| -ne  || if a != b || bne  || bneal  || brne  || sne&lt;br /&gt;
|-&lt;br /&gt;
| -nez || if a != 0 || bnez || bnezal || brnez || snez&lt;br /&gt;
|-&lt;br /&gt;
| -nan || if a == NaN || bnan ||  || brnan || snan&lt;br /&gt;
|-&lt;br /&gt;
| -nanz || if a != NaN ||  ||  || || snanz&lt;br /&gt;
|-&lt;br /&gt;
| -dns || if device d is not set          || bdns || bdnsal || brdns || sdns&lt;br /&gt;
|-&lt;br /&gt;
| -dse || if device d is set              || bdse || bdseal || brdse || sdse&lt;br /&gt;
|-&lt;br /&gt;
| -ap  || if a approximately equals b     || bap  || bapal  || brap  || sap&lt;br /&gt;
|-&lt;br /&gt;
| -apz || if a approximately equals 0     || bapz || bapzal || brapz || sapz&lt;br /&gt;
|-&lt;br /&gt;
| -na  || if a not approximately equals b || bna  || bnaal  || brna  || sna&lt;br /&gt;
|-&lt;br /&gt;
| -naz || if a not approximately equals 0 || bnaz || bnazal || brnaz || snaz&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All &amp;lt;code&amp;gt;b-&amp;lt;/code&amp;gt; commands require target line as last argument, all &amp;lt;code&amp;gt;s-&amp;lt;/code&amp;gt; commands require register to store result as first argument. All &amp;lt;code&amp;gt;br-&amp;lt;/code&amp;gt; commands require number to jump relatively as last argument. e.g. &amp;lt;code&amp;gt;breq a b 3&amp;lt;/code&amp;gt; means if a=b then jump to 3 lines after.&lt;br /&gt;
&lt;br /&gt;
All approximate functions require additional argument denoting how close two numbers need to be considered equal. E.g.: &amp;lt;code&amp;gt;sap r0 100 101 0.01&amp;lt;/code&amp;gt; will consider 100 and 101 almost equal (not more than 1%=0.01 different) and will set r0 to 1. The exact formula is &amp;lt;code&amp;gt;if abs(a - b) &amp;lt;= max(c * max(abs(a), abs(b)), float.epsilon * 8)&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;-ap&amp;lt;/code&amp;gt; and is similar for other approximate functions.&lt;br /&gt;
&lt;br /&gt;
https://en.wikipedia.org/wiki/Machine_epsilon&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
  FLT_EPSILON = 2^(−23) ≈ 1.19e−07;        &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;float (32 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
  DBL_EPSILON = 2^(−52) ≈ 2.20e−16;        &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;double (64 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(100 - 101) &amp;lt;= max(0.01 * max(abs(100), abs(101)), float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(-1) &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if 1 &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, FLT_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, DBL_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 1.19e−07 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 2.20e−16 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.000000952)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.00000000000000176)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Device Variables==&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Activate&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Activate&lt;br /&gt;
:1 if device is activated (usually means running), otherwise 0&lt;br /&gt;
:&amp;lt;code&amp;gt;l r0 d0 Activate # sets r0 to 1 if on or 0 if off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;AirRelease&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;AirRelease&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
:    The current charge the device has.&lt;br /&gt;
&amp;lt;div id=&amp;quot;CLearMemory&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ClearMemory&lt;br /&gt;
:    When set to 1, clears the counter memory (e.g. ExportCount).  Will set itself back to 0 when triggered.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Color&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#212AA5;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;0 (or lower) = Blue&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#7B7B7B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;1 = Grey &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#3F9B39;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;2 = Green &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FF662B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;3 = Orange &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E70200;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;4 = Red &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FFBC1B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;5 = Yellow &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E7E7E7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;6 = White &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#080908;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;7 = Black &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#633C2B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;8 = Brown &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#63633F;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;9 = Khaki &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E41C99;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;10 = Pink &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#732CA7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;11 (or higher) = Purple &lt;br /&gt;
&amp;lt;div id=&amp;quot;CompletionRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;CompletionRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorLevel&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorLevel&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorSpeed&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorSpeed&lt;br /&gt;
&amp;lt;div id=&amp;quot;Error&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Error&lt;br /&gt;
:	1 if device is in error state, otherwise 0&lt;br /&gt;
&amp;lt;div id=&amp;quot;ExportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ExportCount&lt;br /&gt;
:    How many items exporfted since last ClearMemory.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Filtration&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Filtration&lt;br /&gt;
:	The current state of the filtration system.  For example filtration = 1 for a Hardsuit when filtration is On.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Harvest&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Harvest&lt;br /&gt;
:	Performs the harvesting action for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Harvest 1 # Performs 1 harvest action on device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Horizontal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Horizontal&lt;br /&gt;
&amp;lt;div id=&amp;quot;HorizontalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;HorizontalRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Idle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Idle&lt;br /&gt;
&amp;lt;div id=&amp;quot;ImportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ImportCount&lt;br /&gt;
&amp;lt;div id=&amp;quot;Lock&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Lock&lt;br /&gt;
&amp;lt;div id=&amp;quot;Maximum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Maximum&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mode&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mode&lt;br /&gt;
&amp;lt;div id=&amp;quot;On&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;On&lt;br /&gt;
&amp;lt;div id=&amp;quot;Open&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Open&lt;br /&gt;
&amp;lt;div id=&amp;quot;Output&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Output&lt;br /&gt;
&amp;lt;div id=&amp;quot;Plant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Plant&lt;br /&gt;
:    Performs the planting operation for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Plant 1 # Plants one crop in device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionX&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionY&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Power&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Power&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerActual&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerActual&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerPotential&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerPotential&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerRequired&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerRequired&lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureExternal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureExternal&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureInteral&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureInteral&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureSetting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureSetting&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
:	Total quantity in the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Ratio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Ratio&lt;br /&gt;
:	Context specific value depending on device, 0 to 1 based ratio.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioCarbonDioxide&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioCarbonDioxide&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioNitrogen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioNitrogen&lt;br /&gt;
:	The ratio of nitrogen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioOxygen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioOxygen&lt;br /&gt;
:	The ratio of oxygen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioPollutant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioPollutant&lt;br /&gt;
:	The ratio of pollutant in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioVolatiles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioVolatiles&lt;br /&gt;
:	The ratio of volatiles in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioWater&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioWater&lt;br /&gt;
:	The ratio of water in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Reagents&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Reagents&lt;br /&gt;
&amp;lt;div id=&amp;quot;RecipeHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RecipeHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequestHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequestHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequiredPower&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequiredPower&lt;br /&gt;
&amp;lt;div id=&amp;quot;Setting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Setting&lt;br /&gt;
&amp;lt;div id=&amp;quot;SolarAngle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;SolarAngle&lt;br /&gt;
:    Solar angle of the device.&lt;br /&gt;
:  &amp;lt;code&amp;gt;l r0 d0 SolarAngle # Sets r0 to the solar angle of d0.&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;TemperatureSettings&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TemperatureSettings&lt;br /&gt;
&amp;lt;div id=&amp;quot;TotalMoles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TotalMoles&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityMagnitude&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityMagnitude&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeX&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeY&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Vertical&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Vertical&lt;br /&gt;
:	Vertical setting of the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;VerticalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VerticalRatio&lt;br /&gt;
:	Ratio of vertical setting for device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Volume&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Volume&lt;br /&gt;
:	Returns the device atmosphere volume&lt;br /&gt;
&lt;br /&gt;
==Slot Variables==&lt;br /&gt;
In general (exceptions exist such as filtration units) slots are assigned as follows.&lt;br /&gt;
:Slot 0: Import&lt;br /&gt;
:Slot 1: Export&lt;br /&gt;
:Slot 2: Inside Machine&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Occupied&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Occupied&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 2 Occupied #Stores 1 in r0 if d0 has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vOccupied dThisVictim 2 Occupied #stores 1 in vOccupied if dThisVictim has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;OccupantHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;OccupantHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
&amp;lt;div id=&amp;quot;Damage&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Damage&lt;br /&gt;
&amp;lt;div id=&amp;quot;Efficiency&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Efficiency&lt;br /&gt;
&amp;lt;div id=&amp;quot;Health&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Health&lt;br /&gt;
&amp;lt;div id=&amp;quot;Growth&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Growth&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Growth # Store the numerical growth stage of d0 in r0&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
&amp;lt;div id=&amp;quot;ChargeRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ChargeRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Class&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Class&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureWaste&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureWaste&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureAir&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureAir&lt;br /&gt;
&amp;lt;div id=&amp;quot;MaxQuantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;MaxQuantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mature&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Mature # Store 1 in r0 if d0 has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vMature dThisVictim 0 Mature # Store 1 in vMature if dThisVictim has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Previous examples were obsolete due to game changes, or confusing, they have been moved into the Discussions section&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Harvie automation===&lt;br /&gt;
This script uses the batch instruction &amp;lt;code&amp;gt;sb ...&amp;lt;/code&amp;gt; to control all Harvie devices on the network. But only one Harvie and one Tray will be the &#039;&#039;master&#039;&#039; and have their values read, the rest of the Harvies will repeat exactly what this unit does. Some problems with this design is that different types of crops mature at different speeds, and if seeds were manually planted and the master unit recieved the first seed, the harvesting action will be performed too early on all the other plants since they are growing a few seconds slower.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Automated Harvie Script}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Automated Harvie Script}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias dHarvie d0&lt;br /&gt;
alias dTray d1&lt;br /&gt;
&lt;br /&gt;
alias rHarvieHash r8&lt;br /&gt;
alias rTrayHash r9&lt;br /&gt;
l rHarvieHash dHarvie PrefabHash&lt;br /&gt;
l rTrayHash dTray PrefabHash&lt;br /&gt;
&lt;br /&gt;
main:&lt;br /&gt;
yield&lt;br /&gt;
#read plant data from the Tray&lt;br /&gt;
ls r0 dTray 0 Mature&lt;br /&gt;
#harvestable plants return 1, young plants return 0&lt;br /&gt;
#nothing planted returns -1&lt;br /&gt;
beq r0 -1 plantCrop&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
ls r0 dTray 0 Seeding&lt;br /&gt;
#seeds available returns 1, all seeds picked returns 0&lt;br /&gt;
#plants too young or old for seeds returns -1&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
plantCrop:&lt;br /&gt;
#stop the planting if no seeds available&lt;br /&gt;
#otherwise it will plant nothing repeatedly&lt;br /&gt;
ls r0 dHarvie 0 Occupied&lt;br /&gt;
beq r0 0 main&lt;br /&gt;
sb rHarvieHash Plant 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
harvestCrop:&lt;br /&gt;
sb rHarvieHash Harvest 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
### End Script ###&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Solar Panel 2-axis tracking===&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Solar Panel 2-axis tracking}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Solar Panel 2-axis tracking}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#2 Axis Solar Tracking adapted from CowsAreEvil.&lt;br /&gt;
#Place all panels in uniform manner.&lt;br /&gt;
#Set one to 15 Vertical(Min value). 0 Horizontal.&lt;br /&gt;
#Take note direction panel faces.&lt;br /&gt;
#Place daylight sensor flat pointing in the direction&lt;br /&gt;
#the panel now faces. (Cable port facing opposite)&lt;br /&gt;
&lt;br /&gt;
#Alias the sensor to d0&lt;br /&gt;
alias sensor d0&lt;br /&gt;
&lt;br /&gt;
# define the Panel variants&lt;br /&gt;
define Heavy -934345724&lt;br /&gt;
define HeavyDual -1545574413&lt;br /&gt;
define Solar -2045627372&lt;br /&gt;
define SolarDual -539224550&lt;br /&gt;
&lt;br /&gt;
start:&lt;br /&gt;
yield&lt;br /&gt;
#Check for daylight.&lt;br /&gt;
l r0 sensor Activate&lt;br /&gt;
beqz r0 reset&lt;br /&gt;
#Read the Horizontal data.&lt;br /&gt;
l r0 sensor Horizontal&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Horizontal r0&lt;br /&gt;
sb HeavyDual Horizontal r0&lt;br /&gt;
sb Solar Horizontal r0&lt;br /&gt;
sb SolarDual Horizontal r0&lt;br /&gt;
#Read the Vertical data and subtract 90&lt;br /&gt;
l r0 sensor Vertical&lt;br /&gt;
sub r0 90 r0&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Vertical r0&lt;br /&gt;
sb HeavyDual Vertical r0&lt;br /&gt;
sb Solar Vertical r0&lt;br /&gt;
sb SolarDual Vertical r0&lt;br /&gt;
j start&lt;br /&gt;
&lt;br /&gt;
reset:&lt;br /&gt;
yield&lt;br /&gt;
sb Heavy Horizontal 270 #Edit this to face sunrise.&lt;br /&gt;
sb HeavyDual Horizontal 270 #Edit this&lt;br /&gt;
sb Solar Horizontal 270 #Edit this&lt;br /&gt;
sb SolarDual Horizontal 270 #Edit this&lt;br /&gt;
sb Heavy Vertical 0&lt;br /&gt;
sb HeavyDual Vertical 0&lt;br /&gt;
sb Solar Vertical 0&lt;br /&gt;
sb SolarDual Vertical 0&lt;br /&gt;
sleep 10&lt;br /&gt;
j start&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===IC10 Schmitt Trigger - Sensor Range Based Device Toggle===&lt;br /&gt;
This script demonstrates the IC10 style Schmitt Trigger Pattern in basic examples using the &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; instruction with its ternary condition to toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state based on a range of sensor readings.  Examples for both styles are provided below, i.e. &#039;cooling&#039; or &#039;heating&#039;, for &#039;below min&#039; or &#039;greater than max&#039; style range-based toggle.  A temperature based control is shown in the examples, but any sensor reading could be used to dynamically toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state such pressure, charge ratio, solar angle, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, IC10 Schmitt Trigger Pattern}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, IC10 Schmitt Trigger Pattern}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Standard - i.e. &amp;quot;cooling&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# higher than TempMax and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# higher than TempMin, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature lower than&lt;br /&gt;
# TempMin, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example1:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMin TempMax&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 sgt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Inverted - i.e. &amp;quot;heating&amp;quot;&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# lower than TempMin and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# lower than TempMax, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature higher than&lt;br /&gt;
# TempMax, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example2:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMax TempMin&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 slt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example2&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Example experiment: how many lines of code are executed each tick?===&lt;br /&gt;
To determine this, a script without &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; will be used. It should have as few lines as possible (so no labels are used, but a reset value at the top will be needed) and count the number of lines, the IC Housing will be used to display the result.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 1   #the first line has number 0&lt;br /&gt;
add r0 r0 3&lt;br /&gt;
s db Setting r0&lt;br /&gt;
j 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Result (the numbers appears every 0.5 seconds):&lt;br /&gt;
&amp;lt;br&amp;gt;127&lt;br /&gt;
&amp;lt;br&amp;gt;256 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;385 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;511 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;640 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;769 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;895 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;1024 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;1153 (+129)&lt;br /&gt;
&lt;br /&gt;
There is a repeating +129, +129, +126 sequence, a hint that the real value is 128. Which also happens to be the number of lines in a script, which makes sense. A variation of this experiment will show that empty rows are also counted towards this number.&lt;br /&gt;
&lt;br /&gt;
===Push &amp;amp; Pop return address when calling multiple levels of functions===&lt;br /&gt;
More advanced scripts, or scripts that wish to be more generic, may want to allow calling more than one level of function. Allowing this requires pushing the current &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register before calling the function, then popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; back afterward.&lt;br /&gt;
&lt;br /&gt;
For example, imagine that the main loop of the code wants to call function &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, which would calculate the panels&#039; orientations, then place them in &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;, and then in turn itself call &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, which would set the orientations of all panels based on the precomputed values of &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;. Doing so requires &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; to push &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, as show in the code below.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
orientPanelsToStar:&lt;br /&gt;
# Save return address set by the &#039;jal&#039; instruction&lt;br /&gt;
push ra&lt;br /&gt;
&lt;br /&gt;
# ...Calculate panels&#039; orientation, for example leaving the results in r0 and r1...&lt;br /&gt;
&lt;br /&gt;
# Now call orientPanelsTo to actually set the panels&#039; orientation&lt;br /&gt;
# based on the computed values of r0 and r1.&lt;br /&gt;
jal orientPanelsTo&lt;br /&gt;
&lt;br /&gt;
# ...Call other functions here if desired...&lt;br /&gt;
&lt;br /&gt;
# Restore the return address of orientPanelsToStar itself&lt;br /&gt;
pop ra&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
&lt;br /&gt;
##########&lt;br /&gt;
&lt;br /&gt;
orientPanelsTo:&lt;br /&gt;
# ...Actually set panels&#039; orientation...&lt;br /&gt;
&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This code would behave incorrectly if &amp;lt;code&amp;gt;push ra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pop ra&amp;lt;/code&amp;gt; were not present: within &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, doing &amp;lt;code&amp;gt;jal orientPanelsTo&amp;lt;/code&amp;gt; would replace the current value of the &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register, permanently erasing where &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; itself should jump back to once done. Pushing and popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; effectively saves its value until we need it again.&lt;br /&gt;
&lt;br /&gt;
(A tempting but wrong approach to &#039;saving&#039; &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; would be to &amp;lt;code&amp;gt;move&amp;lt;/code&amp;gt; it within a different register (e.g. &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt;) before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, however that only permits two levels of functions, since if &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt; itself wants to call another function, it would not be able to use &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; to save its &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register since &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; already saves &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;&#039;s return address. Just pushing/popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; fixes all issues, allowing for a ginormous maximum function call depth of 512!)&lt;br /&gt;
&lt;br /&gt;
As a last note, if the script will push/pop values like &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt;, starting the script by clearing the stack (which where push/pop move the data to) by running &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; is advisable, unless the IC10 chip is not inserted inside an IC Housing (e.g. inserted in the slot of an Air Conditioner), since &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; will cause an error in this case. To do so, run &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; before the script&#039;s main loop.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
----&lt;br /&gt;
* Stationeers online IC10 Emulators so you can develop your code without repeatedly dying in game&lt;br /&gt;
** [https://ic10.dev/] Stationeers Code Simulator&lt;br /&gt;
** [https://ic10emu.dev] Stationeers IC10 Editor &amp;amp; Emulator - A feature packed code editor for Stationeers IC10 code, paired with a robust debugger and emulator. Edit, test, and share code.&lt;br /&gt;
** [https://stationeering.com/tools/ic] Stationeering provides a simulation of the IC10 chip inside Stationeers. IDE with error checking, full visibility of stack and registers.&lt;br /&gt;
* [http://www.easy68k.com/] EASy68K is a 68000 Structured Assembly Language IDE.&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=Traineratwot.stationeers-ic10] syntax highlighting for IC10 MIPS for Visual Studio Code (updated Feb 10th 2022)&lt;br /&gt;
* [https://pastebin.com/6Uw1KSRN] syntax highlighting for IC10 MIPS for KDE kwrite/kate text editor&lt;br /&gt;
* [https://drive.google.com/file/d/1yEsJ-u94OkuMQ8K6fY7Ja1HNpLcAdjo_/view] syntax highlighting for IC10 MIPS for Notepad++&lt;br /&gt;
* [https://drive.google.com/file/d/1Xrv5U0ZI5jDcPv7yX7EAAxaGk5hKP0xO/view?usp=sharing] syntax highlighting for IC10 MIPS for Notepad++ (updated: 11/08/2022)&lt;br /&gt;
* [https://pastebin.com/3kmGy0NN] syntax highlighting for IC10 MIPS for Notepad++ (updated: 23/03/2024)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Index=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|+Functions &lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#abs|abs]]&lt;br /&gt;
*[[#add|add]]&lt;br /&gt;
*[[#alias|alias]]&lt;br /&gt;
*[[#and|and]]&lt;br /&gt;
*[[#beq|beq]]&lt;br /&gt;
*[[#bgez|bgez]]&lt;br /&gt;
*[[#bgtz|bgtz]]&lt;br /&gt;
*[[#blez|blez]]&lt;br /&gt;
*[[#bltz|bltz]]&lt;br /&gt;
*[[#bne|bne]]&lt;br /&gt;
*[[#breq|breq]]&lt;br /&gt;
*[[#brgez|brgez]]&lt;br /&gt;
*[[#brgtz|brgtz]]&lt;br /&gt;
*[[#brlez|brlez]]&lt;br /&gt;
*[[#brltz|brltz]]&lt;br /&gt;
*[[#brne|brne]]&lt;br /&gt;
*[[#ceil|cell]]&lt;br /&gt;
*[[#div|div]]&lt;br /&gt;
*[[#exp|exp]]&lt;br /&gt;
*[[#floor|floor]]&lt;br /&gt;
*[[#j|j]]&lt;br /&gt;
*[[#jr|jr]]&lt;br /&gt;
*[[#l|l]]&lt;br /&gt;
*[[#log|log]]&lt;br /&gt;
*[[#ls|ls]]&lt;br /&gt;
*[[#max|max]]&lt;br /&gt;
*[[#min|min]]&lt;br /&gt;
*[[#mod|mod]]&lt;br /&gt;
*[[#move|move]]&lt;br /&gt;
*[[#mul|mul]]&lt;br /&gt;
*[[#nor|nor]]&lt;br /&gt;
*[[#or|or]]&lt;br /&gt;
*[[#rand|rand]]&lt;br /&gt;
*[[#round|round]]&lt;br /&gt;
*[[#s|s]]&lt;br /&gt;
*[[#slt|slt]]&lt;br /&gt;
*[[#sqrt|sqrt]]&lt;br /&gt;
*[[#sub|sub]]&lt;br /&gt;
*[[#trunc|trunc]]&lt;br /&gt;
*[[#xor|xor]]xor&lt;br /&gt;
*[[#yield|yield]]&lt;br /&gt;
*[[##|#]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|+Device Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Activate|Activate]]&lt;br /&gt;
*[[#AirRelease|AirRelease]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#CLearMemory|CLearMemory]]&lt;br /&gt;
*[[#Color|Color]]&lt;br /&gt;
*[[#CompletionRatio|CompletionRatio]]&lt;br /&gt;
*[[#ElevatorLevel|ElevatorLevel]]&lt;br /&gt;
*[[#ElevatorSpeed|ElevatorSpeed]]&lt;br /&gt;
*[[#Error|Error]]&lt;br /&gt;
*[[#ExportCount|ExportCount]]&lt;br /&gt;
*[[#Filtration|Filtration]]&lt;br /&gt;
*[[#Harvest|Harvest]]&lt;br /&gt;
*[[#Horizontal|Horizontal]]&lt;br /&gt;
*[[#HorizontalRatio|HorizontalRatio]]&lt;br /&gt;
*[[#Idle|Idle]]&lt;br /&gt;
*[[#ImportCount|ImportCount]]&lt;br /&gt;
*[[#Lock|Lock]]&lt;br /&gt;
*[[#Maximum|Maximum]]&lt;br /&gt;
*[[#Mode|Mode]]&lt;br /&gt;
*[[#On|On]]&lt;br /&gt;
*[[#Open|Open]]&lt;br /&gt;
*[[#Output|Output]]&lt;br /&gt;
*[[#Plant|Plant]]&lt;br /&gt;
*[[#PositionX|PositionX]]&lt;br /&gt;
*[[#PositionY|PositionY]]&lt;br /&gt;
*[[#PositionZ|PositionZ]]&lt;br /&gt;
*[[#Power|Power]]&lt;br /&gt;
*[[#PowerActual|PowerActual]]&lt;br /&gt;
*[[#PowerPotential|PowerPotential]]&lt;br /&gt;
*[[#PowerRequired|PowerRequired]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#PressureExternal|PressureExternal]]&lt;br /&gt;
*[[#PressureInteral|PressureInteral]]&lt;br /&gt;
*[[#PressureSetting|PressureSetting]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Ratio|Ratio]]&lt;br /&gt;
*[[#RatioCarbonDioxide|RatioCarbonDioxide]]&lt;br /&gt;
*[[#RatioNitrogen|RatioNitrogen]]&lt;br /&gt;
*[[#RatioOxygen|RatioOxygen]]&lt;br /&gt;
*[[#RatioPollutant|RatioPollutant]]&lt;br /&gt;
*[[#RatioVolatiles|RatioVolatiles]]&lt;br /&gt;
*[[#RatioWater|RatioWater]]&lt;br /&gt;
*[[#Reagents|Reagents]]&lt;br /&gt;
*[[#RecipeHash|RecipeHash]]&lt;br /&gt;
*[[#RequestHash|RequestHash]]&lt;br /&gt;
*[[#RequiredPower|RequiredPower]]&lt;br /&gt;
*[[#Setting|Setting]]&lt;br /&gt;
*[[#SolarAngle|SolarAngle]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#TemperatureSettings|TemperatureSettings]]&lt;br /&gt;
*[[#TotalMoles|TotalMoles]]&lt;br /&gt;
*[[#VelocityMagnitude|VelocityMagnitude]]&lt;br /&gt;
*[[#VelocityRelativeX|VelocityRelativeX]]&lt;br /&gt;
*[[#VelocityRelativeY|VelocityRelativeY]]&lt;br /&gt;
*[[#VelocityRelativeZ|VelocityRelativeZ]]&lt;br /&gt;
*[[#Vertical|Vertical]]&lt;br /&gt;
*[[#VerticalRatio|VerticalRatio]]&lt;br /&gt;
*[[#Volume|Volume]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|+Slot Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Occupied|Occupied]]&lt;br /&gt;
*[[#OccupantHash|OccupantHash]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Damage|Damage]]&lt;br /&gt;
*[[#Efficiency|Efficiency]]&lt;br /&gt;
*[[#Health|Health]]&lt;br /&gt;
*[[#Growth|Growth]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#ChargeRatio|ChargeRatio]]&lt;br /&gt;
*[[#Class|Class]]&lt;br /&gt;
*[[#PressureWaste|PressureWaste]]&lt;br /&gt;
*[[#PressureAir|PressureAir]]&lt;br /&gt;
*[[#MaxQuantity|MaxQuantity]]&lt;br /&gt;
*[[#Mature|Mature]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=IC10&amp;diff=22950</id>
		<title>IC10</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=IC10&amp;diff=22950"/>
		<updated>2025-08-06T20:21:52Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:IC10 Programming]]&lt;br /&gt;
=Scripting language for IC10 housings / chips=&lt;br /&gt;
MIPS is [[Stationeers]]&#039; inspiration for the in-game scripting language called IC10. It runs on [[Integrated Circuit (IC10)|IC10 chips]] crafted at the [[Electronics Printer]]. &lt;br /&gt;
&lt;br /&gt;
==Registers==&lt;br /&gt;
Internal registers &#039;&#039;&#039;r?&#039;&#039;&#039;: The IC contains 16 CPU registers, numbered &#039;&#039;&#039;r0&#039;&#039;&#039; to &#039;&#039;&#039;r15&#039;&#039;&#039;. From now on referred to as &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Device registers &#039;&#039;&#039;d? logicType&#039;&#039;&#039;: Device registers are written to and from the IC. A device register is numbered &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039; (select via screw), or &#039;&#039;&#039;db&#039;&#039;&#039; (connected device). From now on referred to as &#039;&#039;&#039;d?&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Logic and algorithmic with &#039;&#039;&#039;Internal registers&#039;&#039;&#039; ===&lt;br /&gt;
All calculations are exclusively performed to and from &#039;&#039;&#039;r?&#039;&#039;&#039; registers, or generally more understood as variables in programming. You can use aliases to give convenient names with the &amp;lt;code&amp;gt;alias string r?|d?&amp;lt;/code&amp;gt;command (see below). &lt;br /&gt;
&lt;br /&gt;
Internal registers can be manipulated in various ways. &lt;br /&gt;
* Write constant values &amp;lt;code&amp;gt;move r? (r?|num)&amp;lt;/code&amp;gt;: Example: &amp;lt;code&amp;gt;move r0 2&amp;lt;/code&amp;gt; sets r0 to the number 2.&lt;br /&gt;
* Calculate: Calculations are done to- and from these registers, like &amp;lt;code&amp;gt;add r? a(r?|num) b(r?|num)&amp;lt;/code&amp;gt;. Example: &amp;lt;code&amp;gt;add r1 r0 3&amp;lt;/code&amp;gt; adds 3 to r0, and writes to r1.&lt;br /&gt;
&lt;br /&gt;
Note, for any kind of if statements or loop behaviours, knowing about labels, branching, and jumps is essential knowledge. See below.&lt;br /&gt;
&lt;br /&gt;
=== IO to &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
Acronym &#039;&#039;&#039;d?&#039;&#039;&#039; stands for device, where ? is a number corresponding to the screw device selector on the socket.&lt;br /&gt;
You can also read/write to the device where the IC is planted in using device &#039;&#039;&#039;db&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Generally, there are up to 6 devices which can be set using the screwdriver &#039;&#039;&#039;d0&#039;&#039;&#039; to &#039;&#039;&#039;d5&#039;&#039;&#039;. A special device register &#039;&#039;&#039;db&#039;&#039;&#039; is the device wherever the IC is mounted upon. Very convenient for atmospheric devices where no separate IC socket is required.&lt;br /&gt;
&lt;br /&gt;
Note, the IC is completely unaware where d? is actually connected to. So if you get a logicType error, check d? number, or check if the screw has been set on the socket. An alias is only convenient to convey what is expected to be set on the d? screw, it does not actually set or program the screw.&lt;br /&gt;
&lt;br /&gt;
* Read from device (load) &amp;lt;code&amp;gt;l r? d? logicType&amp;lt;/code&amp;gt;: Reads logicType, like Pressure from a [[Sensors|gas sensor]], from device d? to register r?. Values can be read from connected devices and put into the register using the &#039;&#039;&#039;l&#039;&#039;&#039; (load) command. For example, if you want to load the state of a door. &amp;lt;br&amp;gt; Example: &amp;lt;code&amp;gt;l r0 Door Open&amp;lt;/code&amp;gt; reads the &#039;Open&#039; field of an object named &#039;Door&#039;, that would be connected to the IC housing of the chip.&lt;br /&gt;
* Write to a device (set) &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;: Write a value from a register back to a device using the command &amp;lt;code&amp;gt;s d? logicType r?&amp;lt;/code&amp;gt;. For example, if d0 is set to a door using the screwdriver, &amp;lt;code&amp;gt;s d0 Open 0&amp;lt;/code&amp;gt; sets the &#039;Open&#039; status of the d0 (a door) to 0, effectively closing the door.&lt;br /&gt;
&lt;br /&gt;
=== batch IO to - &#039;&#039;&#039;Device registers&#039;&#039;&#039; ===&lt;br /&gt;
&#039;&#039;&#039;Batch writing&#039;&#039;&#039; needs to be done to a specific &#039;&#039;&#039;deviceHash&#039;&#039;&#039; instead of d?. Is unique per device type, which you can find in the [[Stationpedia]] entries.&lt;br /&gt;
* &amp;lt;code&amp;gt;lb r? deviceHash logicType batchMode&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt;sb deviceHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
Additionally, using the following batch commands, a &#039;&#039;&#039;nameHash&#039;&#039;&#039; can be provided to only modify devices with a certain name.&lt;br /&gt;
* &amp;lt;code&amp;gt;lbn r? deviceHash nameHash logicType batchMode &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sbn deviceHash nameHash logicType r?&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All hashes used in the game are CRC-32 checksums computed from the strings they represent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;batchMode&#039;&#039;&#039; is a parameter equal to 0, 1, 2, or 3. These are also defined as the constants &#039;&#039;&#039;Average&#039;&#039;&#039;, &#039;&#039;&#039;Sum&#039;&#039;&#039;, &#039;&#039;&#039;Minimum&#039;&#039;&#039;, and &#039;&#039;&#039;Maximum&#039;&#039;&#039; respectively. The word or number can be used.&lt;br /&gt;
&lt;br /&gt;
Combining one of these functions with the &amp;lt;code&amp;gt;HASH()&amp;lt;/code&amp;gt; function can be advantageous:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbn r0 HASH(&amp;quot;StructureGasSensor&amp;quot;) HASH(&amp;quot;Sensor 1&amp;quot;) Temperature Average&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will load the average temperature of all gas sensors on the network named &amp;quot;Sensor 1&amp;quot; onto register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the batch read (lb/lbn) is done on a network without any matching devices the results will be as specified in the table:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Batch read with no devices&lt;br /&gt;
|-&lt;br /&gt;
! Batch Mode !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Average (0) || nan&lt;br /&gt;
|-&lt;br /&gt;
| Sum (1) || 0&lt;br /&gt;
|-&lt;br /&gt;
| Minimum (2) || inf&lt;br /&gt;
|-&lt;br /&gt;
| Maximum (3) || ninf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
Here are some examples demonstrating all three operations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 10&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Sets register &#039;&#039;&#039;r0&#039;&#039;&#039; to the value 10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;move r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Copies the value of register &#039;&#039;&#039;r1&#039;&#039;&#039; to register &#039;&#039;&#039;r0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;l r0 d0 Temperature&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Reads the Temperature parameter from device &#039;&#039;&#039;d0&#039;&#039;&#039; and places the value in register &#039;&#039;&#039;r0&#039;&#039;&#039;.&lt;br /&gt;
Note: not all devices have a Temperature parameter, check the in-game stationpedia.&lt;br /&gt;
&lt;br /&gt;
To set a device specific value (like &#039;&#039;&#039;On&#039;&#039;&#039;), you can write into this value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;s d0 On r0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;Writes the value from register &#039;&#039;&#039;r0&#039;&#039;&#039; out to &#039;&#039;&#039;On&#039;&#039;&#039; parameter of device &#039;&#039;&#039;d0&#039;&#039;&#039;. In this example the device will be turned On, if valve of register r0 equals 1, otherwise (register r0 equals 0) it will turned off. See section [[IC10#Device_Variables|Device Variables]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s recommended to use labels (like: &#039;&#039;someVariable&#039;&#039;) instead of a direct reference to the register. See &#039;&#039;&#039;alias&#039;&#039;&#039; in section [[IC10#Instructions|Instructions]].&lt;br /&gt;
&lt;br /&gt;
=== Special registers ===&lt;br /&gt;
There are two more registers. One called &#039;&#039;&#039;ra&#039;&#039;&#039; (return address) and one called &#039;&#039;&#039;sp&#039;&#039;&#039; (stack pointer). The &#039;&#039;&#039;ra&#039;&#039;&#039; is used by certain jump and branching instructions (those ending with &#039;&#039;&#039;-al&#039;&#039;&#039;) to remember which line in the script it should return to. The &#039;&#039;&#039;sp&#039;&#039;&#039; tracks the next index within the stack (a memory that can store up to 512 values) to be pushed (written) to or popped (read) from. Neither &#039;&#039;&#039;ra&#039;&#039;&#039; or &#039;&#039;&#039;sp&#039;&#039;&#039; is protected, their values can be changed by instructions like any other register.&lt;br /&gt;
&lt;br /&gt;
==Stack Memory==&lt;br /&gt;
The Stack is a memory that can hold 512 different values. Each IC10 has its own Stack, and some devices (like the Logical Sorter) also have a Stack.&lt;br /&gt;
;push r?: adds the value  &#039;&#039;&#039;r?&#039;&#039;&#039; and increments the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;pop r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039; and decrements the &#039;&#039;&#039;sp&#039;&#039;&#039; by 1.&lt;br /&gt;
;peek r?: loads the value in the stack memory at index &amp;lt;code&amp;gt;sp-1&amp;lt;/code&amp;gt; into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;get r? d? address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;getd r? id(r?|num) address(r?|num): loads the value in the stack memory at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; on provided device id into register &#039;&#039;&#039;r?&#039;&#039;&#039;.&lt;br /&gt;
;put d? address(r?|num) value(r?|num): adds the value to the stack memory off the provided device at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
;putd id(r?|num) address(r?|num) value(r?|num) : adds the value to the stack memory off the provided device id at index &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, &#039;&#039;&#039;sp&#039;&#039;&#039; can be both written to and read from any time. When reading (&#039;&#039;&#039;peek&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 1 and 512, inclusive. While writing (&#039;&#039;&#039;push&#039;&#039;&#039;), &#039;&#039;&#039;sp&#039;&#039;&#039; must be between 0 and 511, inclusive.&lt;br /&gt;
&lt;br /&gt;
Stack memory is persistent on logic chips. This means that if you have a logic chip and push values to the stack, the code that pushes those values can be removed and the stack will retain those values.&lt;br /&gt;
&lt;br /&gt;
Note that this does not carry over to any other logic chips which receive the program of the original; They will need to have their stack memories programmed individually.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stack Traversing&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Traversing the stack can be done similarly to how an array would be traversed in some other languages:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#this will traverse indices {min value} through {max value}-1&lt;br /&gt;
move sp {min value}&lt;br /&gt;
loop:&lt;br /&gt;
add sp sp 1&lt;br /&gt;
peek r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
blt sp {max value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the pop function&#039;s decrementing to make a more efficient loop:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move sp {max value}&lt;br /&gt;
add sp sp 1&lt;br /&gt;
loop:&lt;br /&gt;
pop r0&lt;br /&gt;
&lt;br /&gt;
#do something here with your stack values (loaded into r0)&lt;br /&gt;
&lt;br /&gt;
bgt sp {min value} loop&lt;br /&gt;
&lt;br /&gt;
#continue on&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments can be placed using a &#039;&#039;&#039;#&#039;&#039;&#039; symbol. All comments are ignored by the game when it reads commands. Below is an example of valid code with two comments.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias MyAlias r0 # Text after the hash tag will be ignored to the end of the line.&lt;br /&gt;
# You can also write comments on their own lines, like this.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Device Ports==&lt;br /&gt;
ICs can interact with up to 6 other devices via d0 - d5, as well as the device it&#039;s attached to via db. To change or set a device, use a screwdriver and adjust the device in the IC housing. You can read or set any of the device&#039;s properties, so it is possible to do things like read the pressure or oxygen content of a room on the same Device port. &lt;br /&gt;
&lt;br /&gt;
Additionally, is possible to set other IC housings as devices, allowing you to create programs that run across multiple ICs together. For example, an Gas Mixing IC could check the &#039;&#039;&#039; Setting&#039;&#039;&#039;  field of a Atmosphere Sensor IC and act based on the value of the sensor chip.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;l&#039;&#039;&#039; (load) or &#039;&#039;&#039;s&#039;&#039;&#039; (set) instructions you have to read or set these values to your device. Examples:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#Reads the &#039;Temperature&#039; from an atmosphere sensor&lt;br /&gt;
# at device port &#039;d0&#039; into register &#039;r0&#039;.&lt;br /&gt;
l r0 d0 Temperature&lt;br /&gt;
}} &lt;br /&gt;
{{ICCode|&lt;br /&gt;
# Writes the value of the register &#039;r0&#039; to the&lt;br /&gt;
# device on port &#039;d1&#039; into the variable &#039;Setting&#039;.&lt;br /&gt;
s d1 Setting r0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are used to make it easier to jump between lines in the script. The label will have a numerical value that is the same as its line number. Even though it&#039;s possible to use a labels value for calculations, doing so is a bad idea since any changes to the code can change the line numbers of the labels.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
main: # define a jump mark with label &#039;main&#039;&lt;br /&gt;
j main # jumps back to &#039;main&#039;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
Instead of using a register to store a fixed value, a constant can be made. Using this name will refer to the assigned value. With the help of Constants you can save register places.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# defines a Constant with name &#039;pi&#039;&lt;br /&gt;
# and set its value to 3.14159&lt;br /&gt;
define pi 3.14159&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
You can use these constants like any other variables (see: alias in section [[IC10#Instructions|Instructions]]). Example:&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# set the value of register &#039;r0&#039; to the value of constant named &#039;pi&#039;.&lt;br /&gt;
move r0 pi &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Numeric values==&lt;br /&gt;
Registers and constants are usually decimal values using double-precision floating point (confirmed?).&lt;br /&gt;
&lt;br /&gt;
Unlike real CPU architectures, integers are not supported as a distinct type, but double FP can represent integers up to about 54 bits before rounding causes problems (the exact number depending what bit patterns you happen to have).&lt;br /&gt;
&lt;br /&gt;
Numbers can be written in hexadecimal by preceding the value with a $ symbol. Values larger than 54 bits might get corrupted. Hex numbers are typically used for ReferenceId values.&lt;br /&gt;
&lt;br /&gt;
Examples: &lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 12345&lt;br /&gt;
move r1 123.456&lt;br /&gt;
move r2 $E1B2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Indirect referencing==&lt;br /&gt;
This is a way of accessing a register by using another register as a pointer. Adding an additional r in front of the register turns on this behaviour. The value stored in the register being used as the pointer must be between 0 to 15, this will then point to a register from r0 to r15, higher or lower values will cause an error.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 5 # stores the value 5 in r0&lt;br /&gt;
move rr0 10 &lt;br /&gt;
# is now the same as &#039;move r5 10&#039; &lt;br /&gt;
# since r0 has the value 5, rr0 points at the register r5&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Additional r&#039;s can be added to do indirect referencing multiple times in a row.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r1 2&lt;br /&gt;
move r2 3&lt;br /&gt;
move rrr1 4&lt;br /&gt;
# is now the same as &#039;move r3 4&#039;&lt;br /&gt;
# since r1 points at r2 which points at r3&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This also works with devices&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 2 # stores the value 2 in r0&lt;br /&gt;
s dr0 On 1 &lt;br /&gt;
# is now the same as &#039;s d2 On 1&#039;&lt;br /&gt;
# r0 has the value 2 so dr0 points at d2&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Dynamically changing LogicType when interacting with Device Registers ==&lt;br /&gt;
When the &amp;lt;code&amp;gt;l&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; instructions are used to read from or write to a Device Register, the LogicType is the variable that will be interacted with (example: in &amp;lt;code&amp;gt;l r0 myDevice Temperature&amp;lt;/code&amp;gt; the LogicType is the Temperature). In most scripts the LogicType will be hardcoded. But it&#039;s also possible to change the LogicType dynamically. The LogicType is an enum, where each type is identified by a unique integer value. This makes it possible to cycle through them in various ways, either as a list placed on the Stack, or by increasing the LogicType value via addition in each loop.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#loop through a list of LogicTypes&lt;br /&gt;
push LogicType.RatioOxygen&lt;br /&gt;
push LogicType.RatioVolatiles&lt;br /&gt;
push LogicType.Temperature&lt;br /&gt;
loop:&lt;br /&gt;
pop r1&lt;br /&gt;
l r0 myDevice r1&lt;br /&gt;
...&lt;br /&gt;
bgtz sp loop #loop until the Stack is empty}}&lt;br /&gt;
&lt;br /&gt;
==Network Referencing / Channels==&lt;br /&gt;
&lt;br /&gt;
All cable networks have 8 Channels which can have data loaded from/stored to via a device and connection reference. Connections for each supported device are listed in the stationpedia. All &#039;connections&#039; a device can make are a connection (pipe, chute, cable), but only cable networks have channels.&lt;br /&gt;
&lt;br /&gt;
The 8 channels (Channel0 to Channel7) are however volatile, in that data is destroyed if any part of the cable network is changed, removed, or added to, and also whenever the world is exited. All these channels default to NaN. Strictly speaking, they default to what we would call &amp;quot;quiet NaN&amp;quot;, in that its not an error it simply means its not a number yet. Recommend you use these channels for reading and writing between networks, rather than as a data store. This effectively means an IC can read all the networks for all devices to connected to it, so not just their own local network, but any networks any device they can reference is connected to.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# d0 is device zero, and the :0 refers&lt;br /&gt;
# to that device&#039;s 0 connection&lt;br /&gt;
l r0 d0:0 Channel0}}&lt;br /&gt;
&lt;br /&gt;
For example: on an IC Housing, the 0 connection is the data port and 1 is power, so you could write out r0 to Channel0 of the power network of the Housing using &amp;lt;code&amp;gt;s db:1 Channel0 r0&amp;lt;/code&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#read all 8 channels with a loop and&lt;br /&gt;
#place the values in r0 to r7&lt;br /&gt;
move r15 LogicType.Channel0 #LogicType integer&lt;br /&gt;
move r14 0 #pointer for indirect referencing&lt;br /&gt;
loop:&lt;br /&gt;
l rr14 db:0 r15&lt;br /&gt;
add r15 r15 1 #next channel&lt;br /&gt;
add r14 r14 1 #next register&lt;br /&gt;
ble r15 LogicType.Channel7 loop&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Logic gates, Bitwise and Logical==&lt;br /&gt;
&lt;br /&gt;
All logic gates in MIPS have a bitwise behavior. The available gates are NOT, AND, OR, XOR and NOR (XNOR and NAND are missing).&lt;br /&gt;
&lt;br /&gt;
In Bitwise operations, each bit is matched separately, which includes the sign bit.&lt;br /&gt;
&lt;br /&gt;
To understand what is going on with bitwise operations, a little bit of computer theory is needed. In Stationeers each register uses 64 bits for integer values (a number without decimals), where the 64th bit is the sign-bit (0 for positive and 1 for negative). Since the number 0 is counted as a positive value, this gives each register a range of (2^63 - 1) to -2^63. Negative numbers also behave according to Two&#039;s complement (https://en.wikipedia.org/wiki/Two%27s_complement). Which means that a number with a sign-bit of 1 will have all of its number bits flipped as well, so that the decimal value of -1 is represented by a binary value of sixtyfour 1&#039;s (this is the smallest possible negative integer since zero counts as a positive integer).&lt;br /&gt;
&lt;br /&gt;
MIPS have binary notation (https://en.wikipedia.org/wiki/Binary_number) that is activated by placing a % in front of the number. The _ characters are ignored and only used for readability.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;not r0 0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 0 = %00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# flip all bits&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# -1 = %11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals -1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;and r0 3 6&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 3 = %011&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# 6 = %110&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# only the bits in the &amp;quot;2&amp;quot; position are matching&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 equals %010 = 2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operations can still be performed via alternative instructions. But these are not perfect substitutes, they treat negative values differently, and some can produce non-binary outputs. When using these, keep in mind that devices that wants a binary value will treat any non-binary values like this: &amp;gt;= 1 counts as &amp;quot;1&amp;quot; and &amp;lt;1 counts as &amp;quot;0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# r0 = result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r1 = input A&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# r2 = input B&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOT = seqz r0 r1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical AND = min r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical OR = max r0 r1 r2&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XOR = sne r0 r1 r2 (only for binary inputs)&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NAND = not and&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical NOR = not or&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Logical XNOR = not xor&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging advices==&lt;br /&gt;
The value stored in a register or variable can easily be displayed by writing it to the Setting parameter of the IC housing. This has no side effects. To see the value, just stand close to the IC housing and look directly at the housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting r0&amp;lt;/code&amp;gt;. # sets/writes the value of register &#039;&#039;&#039;r0&#039;&#039;&#039; into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
To check if a certain block of code is executed, use the above trick but with a random number that you choose, like the line number.&amp;lt;br&amp;gt; This example will display the number 137 on the IC housing.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;s db Setting 137&amp;lt;/code&amp;gt;  # sets/writes the number 137 into the parameter &#039;&#039;&#039;Setting&#039;&#039;&#039; of the IC Housing(&#039;&#039;&#039;db&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Always use unique names for labels. When a label is named after a IC10 keyword like &amp;quot;Temperature:&amp;quot; or &amp;quot;Setting:&amp;quot; the original meaning of the keyword is overwritten, so when an instruction tries to use it an error will occur.&lt;br /&gt;
&lt;br /&gt;
A [[Cartridge#Configuration|configuration cartridge]] installed in a [[Handheld_Tablet|tablet]]  can be used to see all available values and configuration parameter for all devices you focus on.&lt;br /&gt;
&lt;br /&gt;
==Learning IC10==&lt;br /&gt;
IC10 can be difficult to get started with. So here is a list of instructions that are useful for beginners. These can be used to write many different scripts.&lt;br /&gt;
&lt;br /&gt;
General:&lt;br /&gt;
* &amp;lt;code&amp;gt;alias&amp;lt;/code&amp;gt; make the script easier to read by assigning a name to a register or device, example: &amp;lt;code&amp;gt;alias rTemperature r15&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;label:&amp;lt;/code&amp;gt; where &amp;quot;label&amp;quot; can be replaced with almost any word, jump and branch instructions can use these in place of line numbers, example: &amp;lt;code&amp;gt;start:&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; pause for 1-tick and then resume, if not used the script will automatically pause for 1-tick after 128 lines&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Jumps:&lt;br /&gt;
*&amp;lt;code&amp;gt;j someLabelName&amp;lt;/code&amp;gt; jump to line with &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;jal someLabelName&amp;lt;/code&amp;gt; stores the next line number into the register ra (return address) and then jump to &#039;&#039;&#039;someLabelName&#039;&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt; jump to register ra (return address)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Branching (jump-if):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;beq a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if &#039;&#039;&#039;a&#039;&#039;&#039; is equal to &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039;  (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bne a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; not-equal &#039;&#039;&#039;b&#039;&#039;&#039; goto  &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bgt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; greater than &#039;&#039;&#039;b&#039;&#039;&#039; goto   &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;blt a(r?|num) b(r?|num) c(r?|num)&amp;lt;/code&amp;gt; if  &#039;&#039;&#039;a&#039;&#039;&#039; less than &#039;&#039;&#039;b&#039;&#039;&#039; goto &#039;&#039;&#039;c&#039;&#039;&#039; (label or linenumber) &amp;lt;br&amp;gt;&lt;br /&gt;
The suffix -al can be added to each of these (example: beqal) to save the &#039;&#039;&#039;next&#039;&#039;&#039; line number into the &amp;quot;return address&amp;quot; register. this is called using &amp;lt;code&amp;gt;j ra&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Device interactions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
l (load)&lt;br /&gt;
lb (load batch, requires one of the following: 0(Average) / 1(Sum) / 2(Minimum) / 3(Maximum))&lt;br /&gt;
ls (load slot)&lt;br /&gt;
s (store)&lt;br /&gt;
sb (store batch)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Logic and Math:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seqz (common NOT-gate: turns 0 into 1, and all other values into 0)&lt;br /&gt;
move&lt;br /&gt;
add (addition)&lt;br /&gt;
sub (subtraction)&lt;br /&gt;
mul (multiplication)&lt;br /&gt;
div (division)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Common device variables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
On (1 is on, 0 is off)&lt;br /&gt;
Open (1 is open, 0 is closed)&lt;br /&gt;
Setting (meaning varies between devices, example: a LED display(console) will show this value)&lt;br /&gt;
Activate (1 usually means running, example: a Daylight sensor is 1 when the sun shines on it)&lt;br /&gt;
Temperature (in Kelvin, Celsius - 273.15)&lt;br /&gt;
Pressure (in kPa)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Notes:&lt;br /&gt;
&amp;lt;br&amp;gt;-All instructions and variables can be seen in-game in the IC editor window by clicking the &amp;quot;f&amp;quot;, &amp;quot;x&amp;quot; and &amp;quot;s(x)&amp;quot; buttons on the top right.&lt;br /&gt;
&amp;lt;br&amp;gt;-The stationpedia is the best source to see which variables are available to each device.&lt;br /&gt;
&amp;lt;br&amp;gt;-Most scripts are loops, they end with a jump instruction that leads back up to the start. Otherwise they will just run once and then stop.&lt;br /&gt;
&lt;br /&gt;
Two practice scripts:&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Night Light: Load &amp;quot;Activate&amp;quot; from a Daylight sensor, flip the value with a NOT-gate, store the value to the &amp;quot;On&amp;quot; variable of one or more lights.&lt;br /&gt;
&amp;lt;br&amp;gt;Automatic Wall Cooler: Read &amp;quot;Temperature&amp;quot; from a Gas Sensor. Branch if the value is greater than X, turn on the cooler. Branch if the value is less than Y, turn off the cooler. (Wall coolers need a minimum of 12.5 kPa pressure in the connected pipe)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Accessing devices via batch or ReferenceId ==&lt;br /&gt;
&lt;br /&gt;
The IC housing has 6 pins you can use to configure the devices it&lt;br /&gt;
uses.  This provides flexibility to let the installer configure which&lt;br /&gt;
devices will be controlled by the IC.&lt;br /&gt;
&lt;br /&gt;
Alternatives for accessing devices include the batch load/store and&lt;br /&gt;
the ReferenceId load/store instructions.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the average charge ratio across station batteries&lt;br /&gt;
lb r0 HASH(&amp;quot;StructureBattery&amp;quot;) Ratio Average&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# get the ReferenceId for the sorter named &amp;quot;Sorter Corn&amp;quot;&lt;br /&gt;
lbn r1 HASH(&amp;quot;StructureLogicSorter&amp;quot;) HASH(&amp;quot;Sorter Corn&amp;quot;) ReferenceId Maximum&lt;br /&gt;
ble r1 ninf ra&lt;br /&gt;
#use the ReferenceId to set that sorter&#039;s mode.&lt;br /&gt;
sd r1 Mode 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Using the 6 configuration pins makes it easy to write reusable MIPS&lt;br /&gt;
scripts where the installer uses the pins to select the devices that&lt;br /&gt;
will be managed.&lt;br /&gt;
&lt;br /&gt;
Using batch-name instructions frees you from the hassle of adjusting&lt;br /&gt;
the pins, but requires you to name the devices via the [[Labeller]].  It&lt;br /&gt;
can also allow you to control more than 6 devices.&lt;br /&gt;
&lt;br /&gt;
=== Batch instructions ===&lt;br /&gt;
&lt;br /&gt;
The batch instructions can address multiple devices only via their &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; generated from the prefab name using the `HASH(&amp;quot;Name&amp;quot;)` macro or copied directly from the [[Stationpedia]]. A prefab hash is always an integer. All devices that can be read with logic contain the logic value &#039;&#039;&#039;PrefabHash&#039;&#039;&#039; and &#039;&#039;&#039;NameHash&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
See [[#Slot.2FLogic_.2F_Batched|Batched instructions]] for a comprehensive list of all batch instructions.&lt;br /&gt;
&lt;br /&gt;
[[#sb|sb]], [[#sbn|sbn]], [[#sbs|sbs]], (no sbns)&amp;lt;br&amp;gt;&lt;br /&gt;
[[#lb|lb]], [[#lbs|lbs]], [[#lbn|lbn]], [[#lbns|lbns]]&lt;br /&gt;
&lt;br /&gt;
=== Direct reference instructions ===&lt;br /&gt;
&lt;br /&gt;
Direct reference instructions can address a specific device via its &#039;&#039;&#039;ReferenceId&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[#clrd|clrd]], [[#getd|getd]], [[#putd|putd]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[#ld|ld]], [[#sd|sd]], (no slot access via reference ID)&lt;br /&gt;
&lt;br /&gt;
=Instructions=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
See [[IC10/instructions]]&lt;br /&gt;
&lt;br /&gt;
{{:IC10/instructions}}&lt;br /&gt;
&lt;br /&gt;
[https://www.cs.tufts.edu/comp/140/lectures/Day_3/mips_summary.pdf Other examples]&lt;br /&gt;
&lt;br /&gt;
== Conditional functions cheatsheet ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! suffix !! description !! branch to line !! branch and store return address !! relative jump to line !! set register&lt;br /&gt;
|-&lt;br /&gt;
| prefix: ||  || b- || b-al || br- || s-&lt;br /&gt;
|-&lt;br /&gt;
|  || unconditional || j    || jal    || jr    || &lt;br /&gt;
|-&lt;br /&gt;
| -eq  || if a == b || beq  || beqal  || breq  || seq&lt;br /&gt;
|-&lt;br /&gt;
| -eqz || if a == 0 || beqz || beqzal || breqz || seqz&lt;br /&gt;
|-&lt;br /&gt;
| -ge  || if a &amp;gt;= b || bge  || bgeal  || brge  || sge&lt;br /&gt;
|-&lt;br /&gt;
| -gez || if a &amp;gt;= 0 || bgez || bgezal || brgez || sgez&lt;br /&gt;
|-&lt;br /&gt;
| -gt  || if a &amp;gt; b  || bgt  || bgtal  || brgt  || sgt&lt;br /&gt;
|-&lt;br /&gt;
| -gtz || if a &amp;gt; 0  || bgtz || bgtzal || brgtz || sgtz&lt;br /&gt;
|-&lt;br /&gt;
| -le  || if a &amp;lt;= b || ble  || bleal  || brle  || sle&lt;br /&gt;
|-&lt;br /&gt;
| -lez || if a &amp;lt;= 0 || blez || blezal || brlez || slez&lt;br /&gt;
|-&lt;br /&gt;
| -lt  || if a &amp;lt; b  || blt  || bltal  || brlt  || slt&lt;br /&gt;
|-&lt;br /&gt;
| -ltz || if a &amp;lt; 0  || bltz || bltzal || brltz || sltz&lt;br /&gt;
|-&lt;br /&gt;
| -ne  || if a != b || bne  || bneal  || brne  || sne&lt;br /&gt;
|-&lt;br /&gt;
| -nez || if a != 0 || bnez || bnezal || brnez || snez&lt;br /&gt;
|-&lt;br /&gt;
| -nan || if a == NaN || bnan ||  || brnan || snan&lt;br /&gt;
|-&lt;br /&gt;
| -nanz || if a != NaN ||  ||  || || snanz&lt;br /&gt;
|-&lt;br /&gt;
| -dns || if device d is not set          || bdns || bdnsal || brdns || sdns&lt;br /&gt;
|-&lt;br /&gt;
| -dse || if device d is set              || bdse || bdseal || brdse || sdse&lt;br /&gt;
|-&lt;br /&gt;
| -ap  || if a approximately equals b     || bap  || bapal  || brap  || sap&lt;br /&gt;
|-&lt;br /&gt;
| -apz || if a approximately equals 0     || bapz || bapzal || brapz || sapz&lt;br /&gt;
|-&lt;br /&gt;
| -na  || if a not approximately equals b || bna  || bnaal  || brna  || sna&lt;br /&gt;
|-&lt;br /&gt;
| -naz || if a not approximately equals 0 || bnaz || bnazal || brnaz || snaz&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All &amp;lt;code&amp;gt;b-&amp;lt;/code&amp;gt; commands require target line as last argument, all &amp;lt;code&amp;gt;s-&amp;lt;/code&amp;gt; commands require register to store result as first argument. All &amp;lt;code&amp;gt;br-&amp;lt;/code&amp;gt; commands require number to jump relatively as last argument. e.g. &amp;lt;code&amp;gt;breq a b 3&amp;lt;/code&amp;gt; means if a=b then jump to 3 lines after.&lt;br /&gt;
&lt;br /&gt;
All approximate functions require additional argument denoting how close two numbers need to be considered equal. E.g.: &amp;lt;code&amp;gt;sap r0 100 101 0.01&amp;lt;/code&amp;gt; will consider 100 and 101 almost equal (not more than 1%=0.01 different) and will set r0 to 1. The exact formula is &amp;lt;code&amp;gt;if abs(a - b) &amp;lt;= max(c * max(abs(a), abs(b)), float.epsilon * 8)&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;-ap&amp;lt;/code&amp;gt; and is similar for other approximate functions.&lt;br /&gt;
&lt;br /&gt;
https://en.wikipedia.org/wiki/Machine_epsilon&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
  FLT_EPSILON = 2^(−23) ≈ 1.19e−07;        &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;float (32 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
  DBL_EPSILON = 2^(−52) ≈ 2.20e−16;        &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;double (64 bit)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(100 - 101) &amp;lt;= max(0.01 * max(abs(100), abs(101)), float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if abs(-1) &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
  &amp;lt;code&amp;gt;if 1 &amp;lt;= max(0.01 * 101, float.epsilon * 8)&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, FLT_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, DBL_EPSILON * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 1.19e−07 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 2.20e−16 * 8)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.000000952)&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= max(1.01, 0.00000000000000176)&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:#4c9700;&amp;quot;&amp;gt;if 1 &amp;lt;= 1.01   TRUE   1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Device Variables==&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Activate&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Activate&lt;br /&gt;
:1 if device is activated (usually means running), otherwise 0&lt;br /&gt;
:&amp;lt;code&amp;gt;l r0 d0 Activate # sets r0 to 1 if on or 0 if off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;AirRelease&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;AirRelease&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
:    The current charge the device has.&lt;br /&gt;
&amp;lt;div id=&amp;quot;CLearMemory&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ClearMemory&lt;br /&gt;
:    When set to 1, clears the counter memory (e.g. ExportCount).  Will set itself back to 0 when triggered.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Color&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Color&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#212AA5;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;0 (or lower) = Blue&lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#7B7B7B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;1 = Grey &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#3F9B39;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;2 = Green &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FF662B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;3 = Orange &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E70200;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;4 = Red &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FFBC1B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;5 = Yellow &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E7E7E7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;6 = White &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#080908;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;7 = Black &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#633C2B;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;8 = Brown &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#63633F;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;9 = Khaki &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E41C99;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;10 = Pink &lt;br /&gt;
:    &amp;lt;div style=&amp;quot;display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#732CA7;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;amp;nbsp;11 (or higher) = Purple &lt;br /&gt;
&amp;lt;div id=&amp;quot;CompletionRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;CompletionRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorLevel&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorLevel&lt;br /&gt;
&amp;lt;div id=&amp;quot;ElevatorSpeed&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ElevatorSpeed&lt;br /&gt;
&amp;lt;div id=&amp;quot;Error&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Error&lt;br /&gt;
:	1 if device is in error state, otherwise 0&lt;br /&gt;
&amp;lt;div id=&amp;quot;ExportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ExportCount&lt;br /&gt;
:    How many items exporfted since last ClearMemory.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Filtration&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Filtration&lt;br /&gt;
:	The current state of the filtration system.  For example filtration = 1 for a Hardsuit when filtration is On.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Harvest&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Harvest&lt;br /&gt;
:	Performs the harvesting action for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Harvest 1 # Performs 1 harvest action on device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Horizontal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Horizontal&lt;br /&gt;
&amp;lt;div id=&amp;quot;HorizontalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;HorizontalRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Idle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Idle&lt;br /&gt;
&amp;lt;div id=&amp;quot;ImportCount&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ImportCount&lt;br /&gt;
&amp;lt;div id=&amp;quot;Lock&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Lock&lt;br /&gt;
&amp;lt;div id=&amp;quot;Maximum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Maximum&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mode&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mode&lt;br /&gt;
&amp;lt;div id=&amp;quot;On&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;On&lt;br /&gt;
&amp;lt;div id=&amp;quot;Open&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Open&lt;br /&gt;
&amp;lt;div id=&amp;quot;Output&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Output&lt;br /&gt;
&amp;lt;div id=&amp;quot;Plant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Plant&lt;br /&gt;
:    Performs the planting operation for any plant based machinery.&lt;br /&gt;
:  &amp;lt;code&amp;gt;s d0 Plant 1 # Plants one crop in device d0&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionX&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionY&lt;br /&gt;
&amp;lt;div id=&amp;quot;PositionZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PositionZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Power&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Power&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerActual&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerActual&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerPotential&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerPotential&lt;br /&gt;
&amp;lt;div id=&amp;quot;PowerRequired&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PowerRequired&lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureExternal&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureExternal&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureInteral&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureInteral&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureSetting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureSetting&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
:	Total quantity in the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Ratio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Ratio&lt;br /&gt;
:	Context specific value depending on device, 0 to 1 based ratio.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioCarbonDioxide&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioCarbonDioxide&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioNitrogen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioNitrogen&lt;br /&gt;
:	The ratio of nitrogen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioOxygen&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioOxygen&lt;br /&gt;
:	The ratio of oxygen in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioPollutant&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioPollutant&lt;br /&gt;
:	The ratio of pollutant in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioVolatiles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioVolatiles&lt;br /&gt;
:	The ratio of volatiles in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;RatioWater&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RatioWater&lt;br /&gt;
:	The ratio of water in device atmosphere.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Reagents&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Reagents&lt;br /&gt;
&amp;lt;div id=&amp;quot;RecipeHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RecipeHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequestHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequestHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;RequiredPower&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;RequiredPower&lt;br /&gt;
&amp;lt;div id=&amp;quot;Setting&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Setting&lt;br /&gt;
&amp;lt;div id=&amp;quot;SolarAngle&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;SolarAngle&lt;br /&gt;
:    Solar angle of the device.&lt;br /&gt;
:  &amp;lt;code&amp;gt;l r0 d0 SolarAngle # Sets r0 to the solar angle of d0.&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;TemperatureSettings&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TemperatureSettings&lt;br /&gt;
&amp;lt;div id=&amp;quot;TotalMoles&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;TotalMoles&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityMagnitude&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityMagnitude&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeX&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeX&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeY&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeY&lt;br /&gt;
&amp;lt;div id=&amp;quot;VelocityRelativeZ&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VelocityRelativeZ&lt;br /&gt;
&amp;lt;div id=&amp;quot;Vertical&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Vertical&lt;br /&gt;
:	Vertical setting of the device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;VerticalRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;VerticalRatio&lt;br /&gt;
:	Ratio of vertical setting for device.&lt;br /&gt;
&amp;lt;div id=&amp;quot;Volume&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Volume&lt;br /&gt;
:	Returns the device atmosphere volume&lt;br /&gt;
&lt;br /&gt;
==Slot Variables==&lt;br /&gt;
In general (exceptions exist such as filtration units) slots are assigned as follows.&lt;br /&gt;
:Slot 0: Import&lt;br /&gt;
:Slot 1: Export&lt;br /&gt;
:Slot 2: Inside Machine&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Occupied&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Occupied&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 2 Occupied #Stores 1 in r0 if d0 has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vOccupied dThisVictim 2 Occupied #stores 1 in vOccupied if dThisVictim has more seeds&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;OccupantHash&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;OccupantHash&lt;br /&gt;
&amp;lt;div id=&amp;quot;Quantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Quantity&lt;br /&gt;
&amp;lt;div id=&amp;quot;Damage&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Damage&lt;br /&gt;
&amp;lt;div id=&amp;quot;Efficiency&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Efficiency&lt;br /&gt;
&amp;lt;div id=&amp;quot;Health&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Health&lt;br /&gt;
&amp;lt;div id=&amp;quot;Growth&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Growth&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Growth # Store the numerical growth stage of d0 in r0&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;div id=&amp;quot;Pressure&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Pressure&lt;br /&gt;
&amp;lt;div id=&amp;quot;Temperature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Temperature&lt;br /&gt;
&amp;lt;div id=&amp;quot;Charge&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Charge&lt;br /&gt;
&amp;lt;div id=&amp;quot;ChargeRatio&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;ChargeRatio&lt;br /&gt;
&amp;lt;div id=&amp;quot;Class&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Class&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureWaste&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureWaste&lt;br /&gt;
&amp;lt;div id=&amp;quot;PressureAir&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;PressureAir&lt;br /&gt;
&amp;lt;div id=&amp;quot;MaxQuantity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;MaxQuantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Mature&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
;Mature&lt;br /&gt;
:&amp;lt;code&amp;gt;ls r0 d0 0 Mature # Store 1 in r0 if d0 has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ls vMature dThisVictim 0 Mature # Store 1 in vMature if dThisVictim has a mature crop&amp;lt;/code&amp;gt;&lt;br /&gt;
;ReferenceId&lt;br /&gt;
:    Unique Identifier of a Device, this value is different for every device in a save.&lt;br /&gt;
&amp;lt;div id=&amp;quot;ReferenceId&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Previous examples were obsolete due to game changes, or confusing, they have been moved into the Discussions section&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===IC10 Schmitt Trigger - Sensor Range Based Device Toggle===&lt;br /&gt;
This script demonstrates the IC10 style Schmitt Trigger Pattern in basic examples using the &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; instruction with its ternary condition to toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state based on a range of sensor readings.  Examples for both styles are provided below, i.e. &#039;cooling&#039; or &#039;heating&#039;, for &#039;below min&#039; or &#039;greater than max&#039; style range-based toggle.  A temperature based control is shown in the examples, but any sensor reading could be used to dynamically toggle a device &amp;lt;code&amp;gt;On&amp;lt;/code&amp;gt; state such pressure, charge ratio, solar angle, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, IC10 Schmitt Trigger Pattern}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, IC10 Schmitt Trigger Pattern}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Standard - i.e. &amp;quot;cooling&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# higher than TempMax and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# higher than TempMin, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature lower than&lt;br /&gt;
# TempMin, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example1:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMin TempMax&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 sgt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- IC10 Schmitt Trigger ----&lt;br /&gt;
# -- Inverted - i.e. &amp;quot;heating&amp;quot;&lt;br /&gt;
#When the temperature sensor device reports a value&lt;br /&gt;
# lower than TempMin and the valve is not On, the&lt;br /&gt;
# valve will turn On.&lt;br /&gt;
&lt;br /&gt;
#When the valve is On, and the sensor device reports&lt;br /&gt;
# lower than TempMax, the valve will remain on.&lt;br /&gt;
&lt;br /&gt;
#Once that sensor reports a temperature higher than&lt;br /&gt;
# TempMax, the valve will once again shut off and&lt;br /&gt;
# this cycle will continue indefinitely:&lt;br /&gt;
&lt;br /&gt;
define TempMax 296.15 #23C&lt;br /&gt;
define TempMin 283.15 #10C&lt;br /&gt;
&lt;br /&gt;
alias Valve d0&lt;br /&gt;
alias Sensor d1&lt;br /&gt;
&lt;br /&gt;
example2:&lt;br /&gt;
 yield&lt;br /&gt;
 l r0 Valve On&lt;br /&gt;
 select r0 r0 TempMax TempMin&lt;br /&gt;
 l r1 Sensor Temperature&lt;br /&gt;
 slt r0 r1 r0&lt;br /&gt;
 s Valve On r0&lt;br /&gt;
j example2&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Harvie automation===&lt;br /&gt;
This script uses the batch instruction &amp;lt;code&amp;gt;sb ...&amp;lt;/code&amp;gt; to control all Harvie devices on the network. But only one Harvie and one Tray will be the &#039;&#039;master&#039;&#039; and have their values read, the rest of the Harvies will repeat exactly what this unit does. Some problems with this design is that different types of crops mature at different speeds, and if seeds were manually planted and the master unit recieved the first seed, the harvesting action will be performed too early on all the other plants since they are growing a few seconds slower.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Automated Harvie Script}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Automated Harvie Script}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
alias dHarvie d0&lt;br /&gt;
alias dTray d1&lt;br /&gt;
&lt;br /&gt;
alias rHarvieHash r8&lt;br /&gt;
alias rTrayHash r9&lt;br /&gt;
l rHarvieHash dHarvie PrefabHash&lt;br /&gt;
l rTrayHash dTray PrefabHash&lt;br /&gt;
&lt;br /&gt;
main:&lt;br /&gt;
yield&lt;br /&gt;
#read plant data from the Tray&lt;br /&gt;
ls r0 dTray 0 Mature&lt;br /&gt;
#harvestable plants return 1, young plants return 0&lt;br /&gt;
#nothing planted returns -1&lt;br /&gt;
beq r0 -1 plantCrop&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
ls r0 dTray 0 Seeding&lt;br /&gt;
#seeds available returns 1, all seeds picked returns 0&lt;br /&gt;
#plants too young or old for seeds returns -1&lt;br /&gt;
beq r0 1 harvestCrop&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
plantCrop:&lt;br /&gt;
#stop the planting if no seeds available&lt;br /&gt;
#otherwise it will plant nothing repeatedly&lt;br /&gt;
ls r0 dHarvie 0 Occupied&lt;br /&gt;
beq r0 0 main&lt;br /&gt;
sb rHarvieHash Plant 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
harvestCrop:&lt;br /&gt;
sb rHarvieHash Harvest 1&lt;br /&gt;
j main&lt;br /&gt;
&lt;br /&gt;
### End Script ###&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Solar Panel 2-axis tracking===&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot; data-expandtext=&amp;quot;{{int:Expand, Solar Panel 2-axis tracking}}&amp;quot; data-collapsetext=&amp;quot;{{int:Collapse, Solar Panel 2-axis tracking}}&amp;quot;&amp;gt;&lt;br /&gt;
{{ICCode|&lt;br /&gt;
#2 Axis Solar Tracking adapted from CowsAreEvil.&lt;br /&gt;
#Place all panels in uniform manner.&lt;br /&gt;
#Set one to 15 Vertical(Min value). 0 Horizontal.&lt;br /&gt;
#Take note direction panel faces.&lt;br /&gt;
#Place daylight sensor flat pointing in the direction&lt;br /&gt;
#the panel now faces. (Cable port facing opposite)&lt;br /&gt;
&lt;br /&gt;
#Alias the sensor to d0&lt;br /&gt;
alias sensor d0&lt;br /&gt;
&lt;br /&gt;
# define the Panel variants&lt;br /&gt;
define Heavy -934345724&lt;br /&gt;
define HeavyDual -1545574413&lt;br /&gt;
define Solar -2045627372&lt;br /&gt;
define SolarDual -539224550&lt;br /&gt;
&lt;br /&gt;
start:&lt;br /&gt;
yield&lt;br /&gt;
#Check for daylight.&lt;br /&gt;
l r0 sensor Activate&lt;br /&gt;
beqz r0 reset&lt;br /&gt;
#Read the Horizontal data.&lt;br /&gt;
l r0 sensor Horizontal&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Horizontal r0&lt;br /&gt;
sb HeavyDual Horizontal r0&lt;br /&gt;
sb Solar Horizontal r0&lt;br /&gt;
sb SolarDual Horizontal r0&lt;br /&gt;
#Read the Vertical data and subtract 90&lt;br /&gt;
l r0 sensor Vertical&lt;br /&gt;
sub r0 90 r0&lt;br /&gt;
#Set batch to the panels.&lt;br /&gt;
sb Heavy Vertical r0&lt;br /&gt;
sb HeavyDual Vertical r0&lt;br /&gt;
sb Solar Vertical r0&lt;br /&gt;
sb SolarDual Vertical r0&lt;br /&gt;
j start&lt;br /&gt;
&lt;br /&gt;
reset:&lt;br /&gt;
yield&lt;br /&gt;
sb Heavy Horizontal 270 #Edit this to face sunrise.&lt;br /&gt;
sb HeavyDual Horizontal 270 #Edit this&lt;br /&gt;
sb Solar Horizontal 270 #Edit this&lt;br /&gt;
sb SolarDual Horizontal 270 #Edit this&lt;br /&gt;
sb Heavy Vertical 0&lt;br /&gt;
sb HeavyDual Vertical 0&lt;br /&gt;
sb Solar Vertical 0&lt;br /&gt;
sb SolarDual Vertical 0&lt;br /&gt;
sleep 10&lt;br /&gt;
j start&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
===Example experiment: how many lines of code are executed each tick?===&lt;br /&gt;
To determine this, a script without &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; will be used. It should have as few lines as possible (so no labels are used, but a reset value at the top will be needed) and count the number of lines, the IC Housing will be used to display the result.&lt;br /&gt;
{{ICCode|&lt;br /&gt;
move r0 1   #the first line has number 0&lt;br /&gt;
add r0 r0 3&lt;br /&gt;
s db Setting r0&lt;br /&gt;
j 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Result (the numbers appears every 0.5 seconds):&lt;br /&gt;
&amp;lt;br&amp;gt;127&lt;br /&gt;
&amp;lt;br&amp;gt;256 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;385 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;511 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;640 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;769 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;895 (+126)&lt;br /&gt;
&amp;lt;br&amp;gt;1024 (+129)&lt;br /&gt;
&amp;lt;br&amp;gt;1153 (+129)&lt;br /&gt;
&lt;br /&gt;
There is a repeating +129, +129, +126 sequence, a hint that the real value is 128. Which also happens to be the number of lines in a script, which makes sense. A variation of this experiment will show that empty rows are also counted towards this number.&lt;br /&gt;
&lt;br /&gt;
===Push &amp;amp; Pop return address when calling multiple levels of functions===&lt;br /&gt;
More advanced scripts, or scripts that wish to be more generic, may want to allow calling more than one level of function. Allowing this requires pushing the current &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register before calling the function, then popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; back afterward.&lt;br /&gt;
&lt;br /&gt;
For example, imagine that the main loop of the code wants to call function &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, which would calculate the panels&#039; orientations, then place them in &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;, and then in turn itself call &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, which would set the orientations of all panels based on the precomputed values of &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;. Doing so requires &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; to push &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, as show in the code below.&lt;br /&gt;
&lt;br /&gt;
{{ICCode|&lt;br /&gt;
orientPanelsToStar:&lt;br /&gt;
# Save return address set by the &#039;jal&#039; instruction&lt;br /&gt;
push ra&lt;br /&gt;
&lt;br /&gt;
# ...Calculate panels&#039; orientation, for example leaving the results in r0 and r1...&lt;br /&gt;
&lt;br /&gt;
# Now call orientPanelsTo to actually set the panels&#039; orientation&lt;br /&gt;
# based on the computed values of r0 and r1.&lt;br /&gt;
jal orientPanelsTo&lt;br /&gt;
&lt;br /&gt;
# ...Call other functions here if desired...&lt;br /&gt;
&lt;br /&gt;
# Restore the return address of orientPanelsToStar itself&lt;br /&gt;
pop ra&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
&lt;br /&gt;
##########&lt;br /&gt;
&lt;br /&gt;
orientPanelsTo:&lt;br /&gt;
# ...Actually set panels&#039; orientation...&lt;br /&gt;
&lt;br /&gt;
# Return to caller&lt;br /&gt;
j ra&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This code would behave incorrectly if &amp;lt;code&amp;gt;push ra&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pop ra&amp;lt;/code&amp;gt; were not present: within &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;, doing &amp;lt;code&amp;gt;jal orientPanelsTo&amp;lt;/code&amp;gt; would replace the current value of the &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register, permanently erasing where &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt; itself should jump back to once done. Pushing and popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; effectively saves its value until we need it again.&lt;br /&gt;
&lt;br /&gt;
(A tempting but wrong approach to &#039;saving&#039; &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; would be to &amp;lt;code&amp;gt;move&amp;lt;/code&amp;gt; it within a different register (e.g. &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt;) before calling &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt;, however that only permits two levels of functions, since if &amp;lt;code&amp;gt;orientPanelsTo&amp;lt;/code&amp;gt; itself wants to call another function, it would not be able to use &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; to save its &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; register since &amp;lt;code&amp;gt;r15&amp;lt;/code&amp;gt; already saves &amp;lt;code&amp;gt;orientPanelsToStar&amp;lt;/code&amp;gt;&#039;s return address. Just pushing/popping &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt; fixes all issues, allowing for a ginormous maximum function call depth of 512!)&lt;br /&gt;
&lt;br /&gt;
As a last note, if the script will push/pop values like &amp;lt;code&amp;gt;ra&amp;lt;/code&amp;gt;, starting the script by clearing the stack (which where push/pop move the data to) by running &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; is advisable, unless the IC10 chip is not inserted inside an IC Housing (e.g. inserted in the slot of an Air Conditioner), since &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; will cause an error in this case. To do so, run &amp;lt;code&amp;gt;clr db&amp;lt;/code&amp;gt; before the script&#039;s main loop.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
----&lt;br /&gt;
* Stationeers online IC10 Emulators so you can develop your code without repeatedly dying in game&lt;br /&gt;
** [https://ic10.dev/] Stationeers Code Simulator&lt;br /&gt;
** [https://ic10emu.dev] Stationeers IC10 Editor &amp;amp; Emulator - A feature packed code editor for Stationeers IC10 code, paired with a robust debugger and emulator. Edit, test, and share code.&lt;br /&gt;
** [https://stationeering.com/tools/ic] Stationeering provides a simulation of the IC10 chip inside Stationeers. IDE with error checking, full visibility of stack and registers.&lt;br /&gt;
* [http://www.easy68k.com/] EASy68K is a 68000 Structured Assembly Language IDE.&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=Traineratwot.stationeers-ic10] syntax highlighting for IC10 MIPS for Visual Studio Code (updated Feb 10th 2022)&lt;br /&gt;
* [https://pastebin.com/6Uw1KSRN] syntax highlighting for IC10 MIPS for KDE kwrite/kate text editor&lt;br /&gt;
* [https://drive.google.com/file/d/1yEsJ-u94OkuMQ8K6fY7Ja1HNpLcAdjo_/view] syntax highlighting for IC10 MIPS for Notepad++&lt;br /&gt;
* [https://drive.google.com/file/d/1Xrv5U0ZI5jDcPv7yX7EAAxaGk5hKP0xO/view?usp=sharing] syntax highlighting for IC10 MIPS for Notepad++ (updated: 11/08/2022)&lt;br /&gt;
* [https://pastebin.com/3kmGy0NN] syntax highlighting for IC10 MIPS for Notepad++ (updated: 23/03/2024)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Index=&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|+Functions &lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#abs|abs]]&lt;br /&gt;
*[[#add|add]]&lt;br /&gt;
*[[#alias|alias]]&lt;br /&gt;
*[[#and|and]]&lt;br /&gt;
*[[#beq|beq]]&lt;br /&gt;
*[[#bgez|bgez]]&lt;br /&gt;
*[[#bgtz|bgtz]]&lt;br /&gt;
*[[#blez|blez]]&lt;br /&gt;
*[[#bltz|bltz]]&lt;br /&gt;
*[[#bne|bne]]&lt;br /&gt;
*[[#breq|breq]]&lt;br /&gt;
*[[#brgez|brgez]]&lt;br /&gt;
*[[#brgtz|brgtz]]&lt;br /&gt;
*[[#brlez|brlez]]&lt;br /&gt;
*[[#brltz|brltz]]&lt;br /&gt;
*[[#brne|brne]]&lt;br /&gt;
*[[#ceil|cell]]&lt;br /&gt;
*[[#div|div]]&lt;br /&gt;
*[[#exp|exp]]&lt;br /&gt;
*[[#floor|floor]]&lt;br /&gt;
*[[#j|j]]&lt;br /&gt;
*[[#jr|jr]]&lt;br /&gt;
*[[#l|l]]&lt;br /&gt;
*[[#log|log]]&lt;br /&gt;
*[[#ls|ls]]&lt;br /&gt;
*[[#max|max]]&lt;br /&gt;
*[[#min|min]]&lt;br /&gt;
*[[#mod|mod]]&lt;br /&gt;
*[[#move|move]]&lt;br /&gt;
*[[#mul|mul]]&lt;br /&gt;
*[[#nor|nor]]&lt;br /&gt;
*[[#or|or]]&lt;br /&gt;
*[[#rand|rand]]&lt;br /&gt;
*[[#round|round]]&lt;br /&gt;
*[[#s|s]]&lt;br /&gt;
*[[#slt|slt]]&lt;br /&gt;
*[[#sqrt|sqrt]]&lt;br /&gt;
*[[#sub|sub]]&lt;br /&gt;
*[[#trunc|trunc]]&lt;br /&gt;
*[[#xor|xor]]xor&lt;br /&gt;
*[[#yield|yield]]&lt;br /&gt;
*[[##|#]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|+Device Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Activate|Activate]]&lt;br /&gt;
*[[#AirRelease|AirRelease]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#CLearMemory|CLearMemory]]&lt;br /&gt;
*[[#Color|Color]]&lt;br /&gt;
*[[#CompletionRatio|CompletionRatio]]&lt;br /&gt;
*[[#ElevatorLevel|ElevatorLevel]]&lt;br /&gt;
*[[#ElevatorSpeed|ElevatorSpeed]]&lt;br /&gt;
*[[#Error|Error]]&lt;br /&gt;
*[[#ExportCount|ExportCount]]&lt;br /&gt;
*[[#Filtration|Filtration]]&lt;br /&gt;
*[[#Harvest|Harvest]]&lt;br /&gt;
*[[#Horizontal|Horizontal]]&lt;br /&gt;
*[[#HorizontalRatio|HorizontalRatio]]&lt;br /&gt;
*[[#Idle|Idle]]&lt;br /&gt;
*[[#ImportCount|ImportCount]]&lt;br /&gt;
*[[#Lock|Lock]]&lt;br /&gt;
*[[#Maximum|Maximum]]&lt;br /&gt;
*[[#Mode|Mode]]&lt;br /&gt;
*[[#On|On]]&lt;br /&gt;
*[[#Open|Open]]&lt;br /&gt;
*[[#Output|Output]]&lt;br /&gt;
*[[#Plant|Plant]]&lt;br /&gt;
*[[#PositionX|PositionX]]&lt;br /&gt;
*[[#PositionY|PositionY]]&lt;br /&gt;
*[[#PositionZ|PositionZ]]&lt;br /&gt;
*[[#Power|Power]]&lt;br /&gt;
*[[#PowerActual|PowerActual]]&lt;br /&gt;
*[[#PowerPotential|PowerPotential]]&lt;br /&gt;
*[[#PowerRequired|PowerRequired]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#PressureExternal|PressureExternal]]&lt;br /&gt;
*[[#PressureInteral|PressureInteral]]&lt;br /&gt;
*[[#PressureSetting|PressureSetting]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Ratio|Ratio]]&lt;br /&gt;
*[[#RatioCarbonDioxide|RatioCarbonDioxide]]&lt;br /&gt;
*[[#RatioNitrogen|RatioNitrogen]]&lt;br /&gt;
*[[#RatioOxygen|RatioOxygen]]&lt;br /&gt;
*[[#RatioPollutant|RatioPollutant]]&lt;br /&gt;
*[[#RatioVolatiles|RatioVolatiles]]&lt;br /&gt;
*[[#RatioWater|RatioWater]]&lt;br /&gt;
*[[#Reagents|Reagents]]&lt;br /&gt;
*[[#RecipeHash|RecipeHash]]&lt;br /&gt;
*[[#RequestHash|RequestHash]]&lt;br /&gt;
*[[#RequiredPower|RequiredPower]]&lt;br /&gt;
*[[#Setting|Setting]]&lt;br /&gt;
*[[#SolarAngle|SolarAngle]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#TemperatureSettings|TemperatureSettings]]&lt;br /&gt;
*[[#TotalMoles|TotalMoles]]&lt;br /&gt;
*[[#VelocityMagnitude|VelocityMagnitude]]&lt;br /&gt;
*[[#VelocityRelativeX|VelocityRelativeX]]&lt;br /&gt;
*[[#VelocityRelativeY|VelocityRelativeY]]&lt;br /&gt;
*[[#VelocityRelativeZ|VelocityRelativeZ]]&lt;br /&gt;
*[[#Vertical|Vertical]]&lt;br /&gt;
*[[#VerticalRatio|VerticalRatio]]&lt;br /&gt;
*[[#Volume|Volume]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|+Slot Variables &lt;br /&gt;
&amp;lt;div  class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
*[[#Occupied|Occupied]]&lt;br /&gt;
*[[#OccupantHash|OccupantHash]]&lt;br /&gt;
*[[#Quantity|Quantity]]&lt;br /&gt;
*[[#Damage|Damage]]&lt;br /&gt;
*[[#Efficiency|Efficiency]]&lt;br /&gt;
*[[#Health|Health]]&lt;br /&gt;
*[[#Growth|Growth]]&lt;br /&gt;
*[[#Pressure|Pressure]]&lt;br /&gt;
*[[#Temperature|Temperature]]&lt;br /&gt;
*[[#Charge|Charge]]&lt;br /&gt;
*[[#ChargeRatio|ChargeRatio]]&lt;br /&gt;
*[[#Class|Class]]&lt;br /&gt;
*[[#PressureWaste|PressureWaste]]&lt;br /&gt;
*[[#PressureAir|PressureAir]]&lt;br /&gt;
*[[#MaxQuantity|MaxQuantity]]&lt;br /&gt;
*[[#Mature|Mature]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Guide_(Filtration)&amp;diff=22444</id>
		<title>Guide (Filtration)</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Guide_(Filtration)&amp;diff=22444"/>
		<updated>2025-02-16T08:04:21Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Added &amp;#039;see also&amp;#039; section header with link back to Air Filtration Systems page with diagrams&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Place the Kit (Atmospherics) and change the variant to Filtration.&amp;lt;br&amp;gt;&lt;br /&gt;
Place [[filter]]s in the machine for what you want to filter out.&amp;lt;br&amp;gt;&lt;br /&gt;
There are three filtration pipe connections.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Input is where you connect the incoming atmosphere to be passed through the Filtration Atmospherics.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Waste is the remaining mix after extracting whatever the filters did.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Output is the filtered material for which you placed filters in the machine for.&amp;lt;br&amp;gt;&lt;br /&gt;
If run without filters or the filters are exhausted, all input gases will be moved directly to waste.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=See Also=&lt;br /&gt;
* [[Air_Filtration_System]]&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Guide_(Filtration)&amp;diff=22443</id>
		<title>Guide (Filtration)</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Guide_(Filtration)&amp;diff=22443"/>
		<updated>2025-02-16T08:01:02Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Added &amp;#039;see also&amp;#039; with link back to Air Filtration Systems page with diagrams&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Place the Kit (Atmospherics) and change the variant to Filtration.&amp;lt;br&amp;gt;&lt;br /&gt;
Place [[filter]]s in the machine for what you want to filter out.&amp;lt;br&amp;gt;&lt;br /&gt;
There are three filtration pipe connections.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Input is where you connect the incoming atmosphere to be passed through the Filtration Atmospherics.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Waste is the remaining mix after extracting whatever the filters did.&amp;lt;br&amp;gt;&lt;br /&gt;
Filtration Output is the filtered material for which you placed filters in the machine for.&amp;lt;br&amp;gt;&lt;br /&gt;
If run without filters or the filters are exhausted, all input gases will be moved directly to waste.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
(See also [[Air_Filtration_System]] guides with layout diagrams)&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=Air_Filtration_System&amp;diff=22442</id>
		<title>Air Filtration System</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=Air_Filtration_System&amp;diff=22442"/>
		<updated>2025-02-16T07:43:19Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: Added new simplified filtration unit (scrubbing) example and diagram image&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Tutorials]]&lt;br /&gt;
&amp;lt;languages /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
This is an air filtration system that will scrub all bad gases from the air, place them in a tank and cool down the air at the same time.  A second simplified system is listed below, which merely vents any gas not matching base air back to the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
[[File:Filter system.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
=== Filter System (Dual) Items Used === &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* [[Active Vent]]&lt;br /&gt;
* [[Atmospherics|Atmospherics(Filtration)]] &lt;br /&gt;
* [[Filter|Filters (CO2, Pollutant, Volatiles)]]&lt;br /&gt;
* [[Passive Vent]]&lt;br /&gt;
* [[Pipes]]&lt;br /&gt;
* [[Pipe Meter]]&lt;br /&gt;
* [[Pipe Radiator]]&lt;br /&gt;
* [[Pipe Volume Pump]]&lt;br /&gt;
* [[Tank]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
This is a more basic simplified air filtration system, which merely vents any gas not matching base air (Oxygen/Nitrogen) back to the world atmosphere.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
[[File:Filter system BASIC.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
=== Filter System (Basic) Items Used === &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* [[Active Vent]]&lt;br /&gt;
* [[Atmospherics|Atmospherics(Filtration)]] &lt;br /&gt;
* [[Filter|Filters (Oxygen, Nitrogen)]]&lt;br /&gt;
* [[Pipe Valve|One Way Valve (Gas)]]&lt;br /&gt;
* [[Passive Vent]]&lt;br /&gt;
* [[Pipes]]&lt;br /&gt;
* [[Pipe Volume Pump]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
	<entry>
		<id>https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=22441</id>
		<title>File:Filter system BASIC.png</title>
		<link rel="alternate" type="text/html" href="https://stationeers-wiki.com/index.php?title=File:Filter_system_BASIC.png&amp;diff=22441"/>
		<updated>2025-02-16T07:20:37Z</updated>

		<summary type="html">&lt;p&gt;SemlerPDX: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A more simplified basic filtration layout for scrubbing air in a base.&lt;/div&gt;</summary>
		<author><name>SemlerPDX</name></author>
	</entry>
</feed>