## Classes
Create new Mscript interpreter
Mscript

class Mscript

## Functions
startsWith(str, target, position)boolean

startswith function from lodash, do not want the entire lib for this

## Create new Mscript interpreter **Kind**: global class ## Mscript class Mscript **Kind**: global class * [Mscript](#Mscript) * [.clear()](#Mscript+clear) * [.interpret(text, callback)](#Mscript+interpret) ⇒ object * [.variable(line)](#Mscript+variable) * [.variable_replace(line)](#Mscript+variable_replace) ⇒ string * [.basic_cmd(line, short)](#Mscript+basic_cmd) * [.new_loop(line, fade)](#Mscript+new_loop) * [.end_loop(line)](#Mscript+end_loop) * [.move_cam(line)](#Mscript+move_cam) * [.move_cam2(line)](#Mscript+move_cam2) * [.move_proj(line)](#Mscript+move_proj) * [.move_proj2(line)](#Mscript+move_proj2) * [.set_state(line)](#Mscript+set_state) * [.last_loop()](#Mscript+last_loop) ⇒ object * [.parent_loop()](#Mscript+parent_loop) ⇒ object * [.loop_count()](#Mscript+loop_count) ⇒ integer * [.fade(line)](#Mscript+fade) * [.fade_count(str)](#Mscript+fade_count) * [.fade_start(str)](#Mscript+fade_start) ⇒ array * [.fade_end(str)](#Mscript+fade_end) ⇒ array * [.fade_rgb(start, end, len, x)](#Mscript+fade_rgb) ⇒ array * [.rgb(str)](#Mscript+rgb) * [.rgb_str(arr)](#Mscript+rgb_str) ⇒ string * [.update(cmd)](#Mscript+update) * [.str_to_arr(str, cmd)](#Mscript+str_to_arr) ⇒ array * [.light_to_arr(str, cmd)](#Mscript+light_to_arr) ⇒ array * [.light_state(Color)](#Mscript+light_state) * [.delay(line)](#Mscript+delay) * [.alert(line)](#Mscript+alert) * [.pause(line)](#Mscript+pause) * [.fail(msg)](#Mscript+fail) * [.contains(arr, arr2)](#Mscript+contains) ⇒ boolean ### mscript.clear() Clear the state of the script **Kind**: instance method of [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](#Mscript) **Returns**: object - if callback is not provided | Param | Type | Default | 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](#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](#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](#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](#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](#Mscript) | Param | Type | Description | | --- | --- | --- | | line | string | Line to interpret | ### mscript.move\_cam(line) Move camera to explicitly-defined frame **Kind**: instance method of [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](#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](#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](#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](#Mscript) | Param | Type | Description | | --- | --- | --- | | line | string | String containing set statement | ### mscript.last\_loop() ⇒ object Return the last loop **Kind**: instance method of [Mscript](#Mscript) ### mscript.parent\_loop() ⇒ object Return the second-last loop **Kind**: instance method of [Mscript](#Mscript) **Returns**: object - Loop array ### mscript.loop\_count() ⇒ integer Extract the loop count integer from a LOOP cmd **Kind**: instance method of [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](#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](#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](#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](#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](#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](#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](#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](#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](#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](#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](#Mscript) | Param | Type | Description | | --- | --- | --- | | Color | string | string assign to color property | ### mscript.delay(line) Interpret a delay command **Kind**: instance method of [Mscript](#Mscript) | Param | Type | Description | | --- | --- | --- | | line | string | String containing delay command | ### mscript.alert(line) Interpret an alert command **Kind**: instance method of [Mscript](#Mscript) | Param | Type | Description | | --- | --- | --- | | line | string | String containing alert message | ### mscript.pause(line) Interpret an pause command **Kind**: instance method of [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](#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](#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 | ## startsWith(str, target, position) ⇒ boolean startswith function from lodash, do not want the entire lib for this **Kind**: global function **Returns**: boolean - True for match, false for no match | Param | Type | Description | | --- | --- | --- | | str | string | Text to evaluate | | target | string | Text to compare string against | | position | integer | Position in the string to make comparison at |