## lib/mscript
* [lib/mscript](#module_lib/mscript)
* [~Create new Mscript interpreter](#module_lib/mscript..Create new Mscript interpreter)
* [~Mscript](#module_lib/mscript..Mscript)
* [.clear()](#module_lib/mscript..Mscript+clear)
* [.interpret(text, callback)](#module_lib/mscript..Mscript+interpret) ⇒ object
* [.variable(line)](#module_lib/mscript..Mscript+variable)
* [.variable_replace(line)](#module_lib/mscript..Mscript+variable_replace) ⇒ string
* [.basic_cmd(line, short)](#module_lib/mscript..Mscript+basic_cmd)
* [.new_loop(line, fade)](#module_lib/mscript..Mscript+new_loop)
* [.end_loop(line)](#module_lib/mscript..Mscript+end_loop)
* [.move_cam(line)](#module_lib/mscript..Mscript+move_cam)
* [.move_cam2(line)](#module_lib/mscript..Mscript+move_cam2)
* [.move_proj(line)](#module_lib/mscript..Mscript+move_proj)
* [.move_proj2(line)](#module_lib/mscript..Mscript+move_proj2)
* [.set_state(line)](#module_lib/mscript..Mscript+set_state)
* [.last_loop()](#module_lib/mscript..Mscript+last_loop) ⇒ object
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop) ⇒ object
* [.loop_count()](#module_lib/mscript..Mscript+loop_count) ⇒ integer
* [.fade(line)](#module_lib/mscript..Mscript+fade)
* [.fade_count(str)](#module_lib/mscript..Mscript+fade_count)
* [.fade_start(str)](#module_lib/mscript..Mscript+fade_start) ⇒ array
* [.fade_end(str)](#module_lib/mscript..Mscript+fade_end) ⇒ array
* [.fade_rgb(start, end, len, x)](#module_lib/mscript..Mscript+fade_rgb) ⇒ array
* [.rgb(str)](#module_lib/mscript..Mscript+rgb)
* [.rgb_str(arr)](#module_lib/mscript..Mscript+rgb_str) ⇒ string
* [.update(cmd)](#module_lib/mscript..Mscript+update)
* [.str_to_arr(str, cmd)](#module_lib/mscript..Mscript+str_to_arr) ⇒ array
* [.light_to_arr(str, cmd)](#module_lib/mscript..Mscript+light_to_arr) ⇒ array
* [.light_state(Color)](#module_lib/mscript..Mscript+light_state)
* [.delay(line)](#module_lib/mscript..Mscript+delay)
* [.alert(line)](#module_lib/mscript..Mscript+alert)
* [.pause(line)](#module_lib/mscript..Mscript+pause)
* [.fail(msg)](#module_lib/mscript..Mscript+fail)
* [.contains(arr, arr2)](#module_lib/mscript..Mscript+contains) ⇒ boolean
### lib/mscript~Create new Mscript interpreter
**Kind**: inner class of [lib/mscript
](#module_lib/mscript)
### lib/mscript~Mscript
Class representing the mscript language.
**Kind**: inner class of [lib/mscript
](#module_lib/mscript)
* [~Mscript](#module_lib/mscript..Mscript)
* [.clear()](#module_lib/mscript..Mscript+clear)
* [.interpret(text, callback)](#module_lib/mscript..Mscript+interpret) ⇒ object
* [.variable(line)](#module_lib/mscript..Mscript+variable)
* [.variable_replace(line)](#module_lib/mscript..Mscript+variable_replace) ⇒ string
* [.basic_cmd(line, short)](#module_lib/mscript..Mscript+basic_cmd)
* [.new_loop(line, fade)](#module_lib/mscript..Mscript+new_loop)
* [.end_loop(line)](#module_lib/mscript..Mscript+end_loop)
* [.move_cam(line)](#module_lib/mscript..Mscript+move_cam)
* [.move_cam2(line)](#module_lib/mscript..Mscript+move_cam2)
* [.move_proj(line)](#module_lib/mscript..Mscript+move_proj)
* [.move_proj2(line)](#module_lib/mscript..Mscript+move_proj2)
* [.set_state(line)](#module_lib/mscript..Mscript+set_state)
* [.last_loop()](#module_lib/mscript..Mscript+last_loop) ⇒ object
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop) ⇒ object
* [.loop_count()](#module_lib/mscript..Mscript+loop_count) ⇒ integer
* [.fade(line)](#module_lib/mscript..Mscript+fade)
* [.fade_count(str)](#module_lib/mscript..Mscript+fade_count)
* [.fade_start(str)](#module_lib/mscript..Mscript+fade_start) ⇒ array
* [.fade_end(str)](#module_lib/mscript..Mscript+fade_end) ⇒ array
* [.fade_rgb(start, end, len, x)](#module_lib/mscript..Mscript+fade_rgb) ⇒ array
* [.rgb(str)](#module_lib/mscript..Mscript+rgb)
* [.rgb_str(arr)](#module_lib/mscript..Mscript+rgb_str) ⇒ string
* [.update(cmd)](#module_lib/mscript..Mscript+update)
* [.str_to_arr(str, cmd)](#module_lib/mscript..Mscript+str_to_arr) ⇒ array
* [.light_to_arr(str, cmd)](#module_lib/mscript..Mscript+light_to_arr) ⇒ array
* [.light_state(Color)](#module_lib/mscript..Mscript+light_state)
* [.delay(line)](#module_lib/mscript..Mscript+delay)
* [.alert(line)](#module_lib/mscript..Mscript+alert)
* [.pause(line)](#module_lib/mscript..Mscript+pause)
* [.fail(msg)](#module_lib/mscript..Mscript+fail)
* [.contains(arr, arr2)](#module_lib/mscript..Mscript+contains) ⇒ boolean
#### mscript.clear()
Clear the state of the script
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
#### mscript.interpret(text, callback) ⇒ object
Main function, accepts multi-line string, parses into lines
and interprets the instructions from the text. Returns an array
of steps to be fed into the mcopy sequence.
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: object
- if callback is not provided
| Param | Type | Description |
| --- | --- | --- |
| text | string
| Mscript text to interpret |
| callback | function
| Function to call when string is interpreted |
#### mscript.variable(line)
Interprets variables for complex sequence behavior.
TODO: Fully implement, add test coverage
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line containing a variable assignment |
#### mscript.variable\_replace(line) ⇒ string
Replace variable with value at time of interpretation
TODO: Implement this please
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: string
- New string to be interpreted
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line containing variable to be replaced with value |
#### mscript.basic\_cmd(line, short)
Interpret a basic two character command
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line of script to interpret |
| short | string
| The short command to use |
#### mscript.new\_loop(line, fade)
Start a new loop
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line to evaluate as either loop or fade |
| fade | boolean
| Flag as true if fade |
#### mscript.end\_loop(line)
Close the most recent loop
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line to interpret |
#### mscript.move\_cam(line)
Move camera to explicitly-defined frame
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line to interpret with camera move statement |
#### mscript.move\_cam2(line)
Move secondary camera to explicitly-defined frame
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line to interpret with camera move statement |
#### mscript.move\_proj(line)
Move projector to explicitly-defined frame
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line containing `move` statement to interpret |
#### mscript.move\_proj2(line)
Move projector to explicitly-defined frame
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line containing `move` statement to interpret |
#### mscript.set\_state(line)
Set the state of either the cam or projector
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| String containing set statement |
#### mscript.last\_loop() ⇒ object
Return the last loop
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
#### mscript.parent\_loop() ⇒ object
Return the second-last loop
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: object
- Loop array
#### mscript.loop\_count() ⇒ integer
Extract the loop count integer from a LOOP cmd
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: integer
- Loop count in string parsed into integer
#### mscript.fade(line)
Execute a fade of frame length, from color to another color
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| Line containing a fade initiator |
#### mscript.fade\_count(str)
Extract the fade length integer from a FADE cmd
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| str | string
| Line containing the length of fade in frames |
#### mscript.fade\_start(str) ⇒ array
Extract the start color from a string
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: array
- Array containing RGB color values
| Param | Type | Description |
| --- | --- | --- |
| str | string
| Line containing the start color value in a fade initiator |
#### mscript.fade\_end(str) ⇒ array
Extract the end color from a string
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: array
- Array containing RGB color values
| Param | Type | Description |
| --- | --- | --- |
| str | string
| Line containing the end color value in a fade initiator |
#### mscript.fade\_rgb(start, end, len, x) ⇒ array
Determine the state of a fade at a particular frame in the sequence, x
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: array
- Array containing RGB color values
| Param | Type | Description |
| --- | --- | --- |
| start | array
| Color the fade starts at |
| end | array
| Color the fade finishes at |
| len | integer
| Total length of the fade in frames |
| x | integer
| Position of the fade to get color value of |
#### mscript.rgb(str)
Parse string into array of RGB color values. 0-255 octet.
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| str | string
| String containing only color values as `#,#,#` |
#### mscript.rgb\_str(arr) ⇒ string
Cast RGB color values as string
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: string
- String of RGB values
| Param | Type | Description |
| --- | --- | --- |
| arr | array
| Array to join into string |
#### mscript.update(cmd)
Increase the state of a specific object, such as the camera/projector,
by the value defined in val.
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| cmd | string
| String representing command to interpret and update state |
#### mscript.str\_to\_arr(str, cmd) ⇒ array
Split string on command, turn into array of commands
as long as count variable. Default 1.
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: array
- Array containing commands
| Param | Type | Description |
| --- | --- | --- |
| str | string
| String to split |
| cmd | string
| String representing command to split at |
#### mscript.light\_to\_arr(str, cmd) ⇒ array
Split a string on a command to extract data for light array
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: array
- An RGB array containing the color values
| Param | Type | Description |
| --- | --- | --- |
| str | string
| String containing light command |
| cmd | string
| String representing command |
#### mscript.light\_state(Color)
Split a string to extract an rgb color value
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| Color | string
| string assign to color property |
#### mscript.delay(line)
Interpret a delay command
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| String containing delay command |
#### mscript.alert(line)
Interpret an alert command
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| String containing alert message |
#### mscript.pause(line)
Interpret an pause command
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| line | string
| String containing alert message |
#### mscript.fail(msg)
Throw an error with specific message
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
| Param | Type | Description |
| --- | --- | --- |
| msg | string
| Error message to print |
#### mscript.contains(arr, arr2) ⇒ boolean
Determine if array contains matching elements of
another array
**Kind**: instance method of [Mscript
](#module_lib/mscript..Mscript)
**Returns**: boolean
- Whether arr contains elements in arr2
| Param | Type | Description |
| --- | --- | --- |
| arr | Array
| Original array to compare |
| arr2 | Array
| Array to compare elements from |