|
| 1 | +<!-- Generate `description.html` from this by using `$ md2html -o description.html description.md`. --> |
| 2 | +<p>The Microcontroller is a semi-advanced programmable component with a persistent |
| 3 | +256 bit EEPROM memory.</p> |
| 4 | +<p>Warning: This device is largely considered deprecated and might contain bugs. It |
| 5 | +is recommended to use a Luacontroller instead.</p> |
| 6 | +<p>Detailed documentation can be found below:</p> |
| 7 | +<ul> |
| 8 | +<li>The Microcontroller's code is executed whenever any of the following events |
| 9 | +happens:<ul> |
| 10 | +<li>The Microcontroller is programmed. In this case the EEPROM and ports are all |
| 11 | +reset to <code>0</code> before.</li> |
| 12 | +<li>An incoming signal changes its state.</li> |
| 13 | +<li>An <code>after</code> event happens (see command <code>after</code> below).</li> |
| 14 | +</ul> |
| 15 | +</li> |
| 16 | +<li>There are 4 I/O ports (ABCD) and 256 EEPROM bits (1 to 256).</li> |
| 17 | +<li>The code consists of a sequence of commands.</li> |
| 18 | +<li>Everything after <code>:</code> is a comment.</li> |
| 19 | +<li>Strings are enclosed in <code>"</code>s.</li> |
| 20 | +<li>Spaces and tabs outside of strings are ignored.</li> |
| 21 | +<li>Basic command syntax:<pre><code> command_name`(`param1`,` param2`,` ...`)` |
| 22 | +</code></pre> |
| 23 | +</li> |
| 24 | +<li>Commands:<ul> |
| 25 | +<li><code>if(condition) commands [> else_commands];</code>: |
| 26 | +Evaluates the given condition and takes the corresponding branch. |
| 27 | +The else branch is optional (as indicated by the <code>[</code> and <code>]</code>). The <code>></code> is part |
| 28 | +of the syntax and indicates the start of the else branch. The <code>;</code> marks the |
| 29 | +end of the if command.</li> |
| 30 | +<li><code>on(port1, port2, ...)</code>: |
| 31 | +Sets the given ports to <code>1</code>.</li> |
| 32 | +<li><code>off(port1, port2, ...)</code>: |
| 33 | +Sets the given ports to <code>0</code>.</li> |
| 34 | +<li><code>print("string" or codition, ...)</code>: |
| 35 | +Evaluates the conditions and prints the concatenation of all params to stdout |
| 36 | +(only useful in singleplayer).</li> |
| 37 | +<li><code>after(time, "more commands")</code>: |
| 38 | +Executes the commands in the string after the given time in seconds. |
| 39 | +There can only be one waiting <code>after</code> event at once. |
| 40 | +Warning: This is not reliable, ie. <code>minetest.after</code> is used.</li> |
| 41 | +<li><code>sbi(port_or_eeprom, condition)</code>: |
| 42 | +Evaluates the condition and sets the port or EEPROM bit to the resulting value. |
| 43 | +Note: EEPROM indices don't use <code>#</code> here, ie. it's <code>sbi(1, #2)</code>, not <code>sbi(#1, #2)</code>.</li> |
| 44 | +</ul> |
| 45 | +</li> |
| 46 | +<li>Conditions (sorted by descending precedence; they are all evaluated from left |
| 47 | +to right):<ul> |
| 48 | +<li><code>0</code>, <code>1</code>: constant</li> |
| 49 | +<li><code>A</code>, ..., <code>D</code>: value of a port. Takes writes that already happened during the |
| 50 | +current execution into account.</li> |
| 51 | +<li><code>#1</code>, ..., <code>#256</code>: value of an EEPROM bit. Takes writes that already happened |
| 52 | +during the current execution into account.</li> |
| 53 | +<li><code>!condition</code>: negation (can only be applied once, ie. not <code>!!1</code>)</li> |
| 54 | +<li><code>condition1 = condition2</code>: XNOR (equality)</li> |
| 55 | +<li><code>condition1 op condition2</code> where <code>op</code> is one of:<ul> |
| 56 | +<li><code>&</code>: AND</li> |
| 57 | +<li><code>|</code>: OR</li> |
| 58 | +<li><code>~</code>: XOR (inequality)</li> |
| 59 | +</ul> |
| 60 | +</li> |
| 61 | +<li>Note: Explicit precedence using parentheses is not supported.</li> |
| 62 | +</ul> |
| 63 | +</li> |
| 64 | +</ul> |
0 commit comments