Difference between revisions of "Script Editor"

From ModWiki
Jump to: navigation, search
(Created page with "File:Script_editor.png --------- The script editor is a way to trigger changes in mods directly from actions in other mods. It is one of the ways Monomodular seeks to beco...")
 
(Available Commands and Structure)
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
 
For more detailed information of how scripting works, see the entry for [[Help| mod_help]] regarding the new hotline capabilities, as the scripting function is just an extension of those same capabilities.  The scripting engine offers some shortcuts and additional features so that the scripting could be pattr-ized and useful for triggering from existing mods.
 
For more detailed information of how scripting works, see the entry for [[Help| mod_help]] regarding the new hotline capabilities, as the scripting function is just an extension of those same capabilities.  The scripting engine offers some shortcuts and additional features so that the scripting could be pattr-ized and useful for triggering from existing mods.
  
The client  
+
The client setting determines which connected mods will receive the scripting command. 
Syntax and usage is completely dependent upon the mod being transmitted to, but roughly the following rules apply for scripting:
 
  
"multi"  allows sending more than one scripting function at the same time.  scripts are seperated by the "|" character.
+
Syntax and usage is completely dependent upon the mod being transmitted to.
 +
 
 +
==Available Commands and Structure==
 +
 
 +
'''"multi"''' allows sending more than one scripting function at the same time.  scripts are seperated by the "|" character.
  
 
     example:  multi press grid 0 0 | key 2 1 | literal pipe value swing 85
 
     example:  multi press grid 0 0 | key 2 1 | literal pipe value swing 85
Line 20: Line 23:
  
  
"press" sends the scripting command suffixed with one, then again suffixed with 0.  This simulates a press and release function.
+
'''"press"''' sends the scripting command suffixed with one, then again suffixed with 0.  This simulates a press and release function.
  
 
     example:  press key 6
 
     example:  press key 6
Line 27: Line 30:
 
           key 6 0
 
           key 6 0
  
"random" sends a message wherein certain numerical elements are generated randomly to fall withing parameters defined in the scripting message.  The format of the random call is:  *r range start.  "*r" represents the position of the random number in the message, and the two numbers after will determine the range for the number.  "Range" represents the maximum value before the "Start" value is added.  Thus, the message *r 50 5 will yield a random number in the range of 5 and 55.  (r = Math.random() * 50)+5.
+
'''"random"''' sends a message wherein certain numerical elements are generated randomly to fall withing parameters defined in the scripting message.  The format of the random call is:  *r range start.  "*r" represents the position of the random number in the message, and the two numbers after will determine the range for the number.  "Range" represents the maximum value before the "Start" value is added.  Thus, the message *r 50 5 will yield a random number in the range of 5 and 55.  (r = Math.random() * 50)+5.
  
 
       example:  random grid r* 7 0 r* 7 0 r* 1 0
 
       example:  random grid r* 7 0 r* 7 0 r* 1 0
Line 35: Line 38:
  
  
"press_random" sends a press (momentary on/off), but certain elements in the message are randomized based on parameters defined in the scripting message.   
+
'''"press_random"''' sends a press (momentary on/off), but certain elements in the message are randomized based on parameters defined in the scripting message.   
  
 
     example:  press_random grid 0 r* 7 0
 
     example:  press_random grid 0 r* 7 0
Line 41: Line 44:
 
           and then x = 0, y = (whatever the first random number was), 0
 
           and then x = 0, y = (whatever the first random number was), 0
  
"literal" sends exactly what is included in the script window.  Literal commands ignore the client number setting for the assignment, however it needs to be included in the literal in order to function correctly.
+
'''"literal"''' sends exactly what is included in the script window.  Literal commands ignore the client number setting for the assignment, however it needs to be included in the literal in order to function correctly.
  
 
       example:  literal all exclusive testmod blah 128
 
       example:  literal all exclusive testmod blah 128
Line 48: Line 51:
 
             received at its outlet of int(128).  This is really only useful if you know what you are doing (obviously),  
 
             received at its outlet of int(128).  This is really only useful if you know what you are doing (obviously),  
 
             but is pretty powerful if you DO know what you are doing.
 
             but is pretty powerful if you DO know what you are doing.
 +
 +
'''default'''  The default behavior of the script routine is to send the arguments provided in the scripting text box.  The most usual commands are "grid" and "key", but there are plenty of other's available as well.  Each command is transmitted to the mod as though it were sent from a Monomodular capable control surface, allowing automation of most actions that a mod would be capable of from user input.
 +
 +
    examples:  grid 5 6 1
 +
                      key 4 1
 +
                      swing 50
 +
                      alt 1

Latest revision as of 02:49, 8 April 2012

Script editor.png


The script editor is a way to trigger changes in mods directly from actions in other mods. It is one of the ways Monomodular seeks to become a truly modular solution. It is currently available in Plinko and Monotes, but will slowly be incorporated into more mods as it develops and gains further functionality. Currently the syntax is very specific, and use of these commands requires some experimentation and some knowledge of the internal structure of the mods.js. However, by following the examples below you can probably get a better idea of how to structure the syntax. In actuality, there are some very low-level mod functions available through scripting, but correct syntax is paramount to success with these techniques.

For more detailed information of how scripting works, see the entry for mod_help regarding the new hotline capabilities, as the scripting function is just an extension of those same capabilities. The scripting engine offers some shortcuts and additional features so that the scripting could be pattr-ized and useful for triggering from existing mods.

The client setting determines which connected mods will receive the scripting command.

Syntax and usage is completely dependent upon the mod being transmitted to.

Available Commands and Structure

"multi" allows sending more than one scripting function at the same time. scripts are seperated by the "|" character.

    example:  multi press grid 0 0 | key 2 1 | literal pipe value swing 85
    This would send the following commands in sequence:
         grid 0 0 1
         grid 0 0 0
         key 2 1
         pipe value swing 85


"press" sends the scripting command suffixed with one, then again suffixed with 0. This simulates a press and release function.

    example:  press key 6
    This would send the following commands in sequence:
         key 6 1
         key 6 0

"random" sends a message wherein certain numerical elements are generated randomly to fall withing parameters defined in the scripting message. The format of the random call is: *r range start. "*r" represents the position of the random number in the message, and the two numbers after will determine the range for the number. "Range" represents the maximum value before the "Start" value is added. Thus, the message *r 50 5 will yield a random number in the range of 5 and 55. (r = Math.random() * 50)+5.

     example:  random grid r* 7 0 r* 7 0 r* 1 0
     This would send a grid action with random x between 0 and 7, 
           random y between 0 and 7, 
           and random value between 0 and 1.


"press_random" sends a press (momentary on/off), but certain elements in the message are randomized based on parameters defined in the scripting message.

    example:  press_random grid 0 r* 7 0
    This would send a grid press with x = 0, y = random(0 - 7), 1
         and then x = 0, y = (whatever the first random number was), 0

"literal" sends exactly what is included in the script window. Literal commands ignore the client number setting for the assignment, however it needs to be included in the literal in order to function correctly.

     example:  literal all exclusive testmod blah 128
     This would send a command to all connected mods.  If any of those mods were of the type testmod, 
           and a receive object named "---blah" is present in the mod's patcher, then a message will be 
           received at its outlet of int(128).  This is really only useful if you know what you are doing (obviously), 
           but is pretty powerful if you DO know what you are doing.

default The default behavior of the script routine is to send the arguments provided in the scripting text box. The most usual commands are "grid" and "key", but there are plenty of other's available as well. Each command is transmitted to the mod as though it were sent from a Monomodular capable control surface, allowing automation of most actions that a mod would be capable of from user input.

    examples:  grid 5 6 1
                      key 4 1
                      swing 50
                      alt 1