# NetSwarm-Simulator --{{0}}-- This document defines some basic macros for applying the JavaScript Arduino interpreter [NetSwarm](https://github.com/wvengen/netswarm-arduino) in [LiaScript](https://LiaScript.github.io) to make Arduino programs in Markdown executeable and editable. __Try it on LiaScript:__ https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/netswarm-simulator/master/README.md __See the project on Github:__ https://github.com/liaTemplates/netswarm-simulator --{{1}}-- There are three ways to use this template. The easiest way is to use the `import` statement and the url of the raw text-file of the master branch or any other branch or version. But you can also copy the required functionality directly into the header of your Markdown document, see therefor the [last slide](#implementation). And of course, you could also clone this project and change it, as you wish. {{1}} 1. Load the macros via `import: https://raw.githubusercontent.com/liaTemplates/netswarm-simulator/master/README.md` 2. Copy the definitions into your Project 3. Clone this repository on GitHub ## `@NetSwarm.single_loop` --{{0}}-- If you want to execute the loop only once, use `@NetSwarm.single_loop` To use the [Tau-Prolog](http://tau-prolog.org) interpreter, two macros are necessary. The first one is `@Tau.program`, which is called with a unique identifier. It defines the basic Prolog-program with all rules and definitions. ```cpp void setup() { Serial.println("Hello setup."); } void loop() { Serial.println("Hello loop."); } ``` @NetSwarm.single_loop ## `@NetSwarm.sloop` ```cpp void setup() { Serial.println("Hello stuff."); } void thing(char i) { switch(i) { case 0: Serial.println("a pear"); break; case 1: Serial.println("an apple"); break; case 2: Serial.println("an elephant"); break; case 3: Serial.println("an arduino"); break; } } void loop() { Serial.print("here's "); thing(random(4)); } ``` @NetSwarm.loop ## Implementation