t2:gpc_scripting:macros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
t2:gpc_scripting:macros [2019/07/21 01:24]
scachi [Playback]
t2:gpc_scripting:macros [2020/09/15 00:37] (current)
scachi [Playback]
Line 1: Line 1:
 ====== GPC Macros ====== ====== GPC Macros ======
  
-This section is about the **basic macro usage only** (([[t2:​gtuner_iv:​macro_editor_interface|Here is a more detailed tutorial]] about the Macro Editor Interface, //created by [[https://​www.consoletuner.com/​forum/​memberlist.php?​mode=viewprofile&​u=766|prototype]]//​)) to record your inputs as macros and use them in scripts. The maximum length of a single macro file is 24hours. ((More precisely up to 24 days, 20 hours, 31 minutes, 23 seconds and 650 milliseconds))+This section is about the **basic macro usage only** (([[t2:​gtuner_iv:​macro_editor_interface|Here is a more detailed tutorial]] about the Macro Editor Interface, //created by [[https://​www.consoletuner.com/​forum/​memberlist.php?​mode=viewprofile&​u=766|prototype]]//​)) to record your inputs as macros and use them in scripts. The maximum length of a single macro file is 24 days. ((More precisely up to 24 days, 20 hours, 31 minutes, 23 seconds and 650 milliseconds))
  
 ''​While using a macro file directly in a script requires a sd-card you can still use this without one to record your input and convert it to a combo for playback.''​ ''​While using a macro file directly in a script requires a sd-card you can still use this without one to record your input and convert it to a combo for playback.''​
Line 7: Line 7:
 You can playback one macro at a time only.\\ ​ You can playback one macro at a time only.\\ ​
 Converting a macro to a combo has some limitations.((The script size limitation does apply to combos so you can't convert long macros)) ((Regular GPC combos can have to up to 255 states (a state is defined by the wait() statement). However, is possible to chain multiple combos with the call() function, so the maximum length is actually limited by the 8Kb bytecode size)).\\ ​ Converting a macro to a combo has some limitations.((The script size limitation does apply to combos so you can't convert long macros)) ((Regular GPC combos can have to up to 255 states (a state is defined by the wait() statement). However, is possible to chain multiple combos with the call() function, so the maximum length is actually limited by the 8Kb bytecode size)).\\ ​
-There are other reason to use a combo instead of a macro.((Dynamic changes to recorded inputs during playback, playback multiple actions at the same time,..)) \\ +There are other reason to use a combo instead of a macro.((See information **[[t2:​gpc_scripting:​combos#​combo_or_macro|here]]**)) \\ 
 For simple short actions you may want to stick to using [[t2:​gpc_scripting:​combos|combos]] created manually or by converting a macro to a combo. For simple short actions you may want to stick to using [[t2:​gpc_scripting:​combos|combos]] created manually or by converting a macro to a combo.
  
Line 38: Line 38:
  
   * **Using GTuner IV** - You can playback a macro by using the GTuner IV "Macro Editor"​.\\ Double click the macro file name((Macro file extension is .gmk)) in the "File Explorer"​ will open the macro in the "Macro Editor"​. Hit the green play button {{:​t2:​gtuner_iv:​testdebug_toolbar_macro.png?​100|Test and debug active work}} at the top to will start the macro instantly. To stop the playback before it has completed use the "​Unload Memory Slot" button((Memory Slots Control is located at the right side in Gtuner IV {{ :​t2:​gtuner_iv:​memory_slots_control.png?​200 |}}\\ \\ ))   * **Using GTuner IV** - You can playback a macro by using the GTuner IV "Macro Editor"​.\\ Double click the macro file name((Macro file extension is .gmk)) in the "File Explorer"​ will open the macro in the "Macro Editor"​. Hit the green play button {{:​t2:​gtuner_iv:​testdebug_toolbar_macro.png?​100|Test and debug active work}} at the top to will start the macro instantly. To stop the playback before it has completed use the "​Unload Memory Slot" button((Memory Slots Control is located at the right side in Gtuner IV {{ :​t2:​gtuner_iv:​memory_slots_control.png?​200 |}}\\ \\ ))
-  * **Using a script** - To playback a macro without GTuner IV you need to create a script.\\ Here is a basic script example to playback a macro one time when BUTTON_4 is pressed:<​code gpc2>+  * **Using a script** - To playback a macro without GTuner IV you need to copy the macro file to the sd-card (read step 6. above) and create a script.\\ Here is a basic script example to playback a macro one time when BUTTON_4 is pressed:<​code gpc2>
 main { main {
     if(event_active(BUTTON_4)) {     if(event_active(BUTTON_4)) {
Line 45: Line 45:
             macro_run("​Example1.gmk"​);​             macro_run("​Example1.gmk"​);​
     }     }
 +}
 +</​code>​ Here is another script example to play a macro in endless loop when BUTTON_4 is pressed. Hit BUTTON_4 again to stop the playback loop:<​code gpc2>
 +bool bplay=FALSE;​
 +main {
 +    if(event_active(BUTTON_4)) {
 +        bplay=!bplay;​ // inverses the value FALSE<​->​TRUE
 +    }
 +    // replace Example.gmk with the name of yourfile.gmk
 +    // your filename must have 8 characters or less
 +    if (bplay) macro_run("​Example1.gmk"​);​
 +    else macro_stop();​
 } }
 </​code>​ </​code>​
 ===== Convert to Combo ===== ===== Convert to Combo =====
 To get gpc combo code it needs some additional steps. But it is not that complicated or different. To get gpc combo code it needs some additional steps. But it is not that complicated or different.
 +\\ Keep in mind that you can't convert a long macro completely to a combo because of the scripts size limitation.
 +
  
 **The steps to do are:** **The steps to do are:**
t2/gpc_scripting/macros.1563686687.txt.gz · Last modified: 2019/07/21 01:24 by scachi