Matt McWilliams 6c8d2d712d | ||
---|---|---|
.. | ||
Readme.md | ||
TODO.md | ||
index.d.ts | ||
index.js | ||
index.js.map | ||
index.old.js | ||
package.json |
Readme.md
Classes
- Create new Mscript interpreter
- Mscript
class Mscript
Create new Mscript interpreter
Mscript
class Mscript
Kind: global class
- Mscript
- .clear()
- .interpret(text, callback) ⇒
object
- .variable(line)
- .variable_replace(line) ⇒
string
- .basic_cmd(line, short)
- .new_loop(line, fade)
- .end_loop(line)
- .move_cam(line)
- .move_cam2(line)
- .move_proj(line)
- .move_proj2(line)
- .set_state(line)
- .last_loop() ⇒
object
- .parent_loop() ⇒
object
- .loop_count() ⇒
integer
- .fade(line)
- .fade_count(str)
- .fade_start(str) ⇒
array
- .fade_end(str) ⇒
array
- .fade_rgb(start, end, len, x) ⇒
array
- .rgb(str)
- .rgb_str(arr) ⇒
string
- .update(cmd)
- .str_to_arr(str, cmd) ⇒
array
- .light_to_arr(str, cmd) ⇒
array
- .light_state(Color)
- .delay(line)
- .alert(line)
- .pause(line)
- .fail(msg)
- .contains(arr, arr2) ⇒
boolean
mscript.clear()
Clear the state of the script
Kind: instance method of 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
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
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
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
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
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
Param | Type | Description |
---|---|---|
line | string |
Line to interpret |
mscript.move_cam(line)
Move camera to explicitly-defined frame
Kind: instance method of 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
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
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
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
Param | Type | Description |
---|---|---|
line | string |
String containing set statement |
mscript.last_loop() ⇒ object
Return the last loop
Kind: instance method of Mscript
mscript.parent_loop() ⇒ object
Return the second-last loop
Kind: instance method of Mscript
Returns: object
- Loop array
mscript.loop_count() ⇒ integer
Extract the loop count integer from a LOOP cmd
Kind: instance method of 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
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
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
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
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
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
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
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
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
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
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
Param | Type | Description |
---|---|---|
Color | string |
string assign to color property |
mscript.delay(line)
Interpret a delay command
Kind: instance method of Mscript
Param | Type | Description |
---|---|---|
line | string |
String containing delay command |
mscript.alert(line)
Interpret an alert command
Kind: instance method of Mscript
Param | Type | Description |
---|---|---|
line | string |
String containing alert message |
mscript.pause(line)
Interpret an pause command
Kind: instance method of Mscript
Param | Type | Description |
---|---|---|
line | string |
String containing alert message |
mscript.fail(msg)
Throw an error with specific message
Kind: instance method of 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
Returns: boolean
- Whether arr contains elements in arr2
Param | Type | Description |
---|---|---|
arr | Array |
Original array to compare |
arr2 | Array |
Array to compare elements from |