t2:gpc_scripting:macros

This is an old revision of the document!


GPC Macros

This section is about the basic macro usage only 1) to record your inputs as macros and use them in scripts. The maximum length of a single macro file is 24hours. 2)

Converting sections to a combo 3) 4) is also explained when you have no sd-card or for various reasons.5)
For simple short actions you may want to stick to using combos created manually.

If you have no sd-card you can still use this to record you input and convert it to a combo

  • macro_run(“<filename>.gmk”); Run the macro file named <filename> stored on the SD-Card.
  • macro_rec(“<filename>.gmk”); Record the controller outputs to the macro file named <filename> on the SD-Card.
  • macro_time(); Get the time in milli-seconds the macro file is running or recording since initiated by macro_run or macro_rec.
  • macro_stop(); Stop the execution or recording of the macro file initiated by macro_run or macro_rec.

Recording

To record a macro via GTuner IV you need to have:

  • GTuner IV running
  • Your Titan Two connected via PROG port to your computer 6)
  • A controller connected to Input-A or Input-B 7)

In GTuner IV switch to the “Device Monitor”. It will look like this, the areas of interest are marked green:

The steps to do are:

  1. Start recording Click the “REC” button
    The button label changes to a countdown. Get ready to do your inputs when the 3,2,1 countdown ends
  2. Do your inputs
  3. Stop recording Click the “STOP” button
  4. Save Click the “Save” button
    In the “Save As Macro” dialog choose a location and filename 8)
  5. Optionally Edit the recording by opening your .gmk file via double click in the “File Explorer”, it will open the “Macro Editor”. Do your editings 9) and save it again
  6. Copy onto sd-card - If you have no sd-card continue here
    Drag your .gmk file from the “File Explorer” onto the “Macro Explorer (Micro-SD)” dialog

Playback

Here is a basic script example to playback a macro one time when BUTTON_4 is pressed

main {
    if(event_active(BUTTON_4)) {
            macro_run("Example.gmk"); // replace Example.gmk with the name of yourfile.gmk
    }
}

Convert to Combo

To get gpc combo code it needs some additional steps. But it is not that complicated or different.

The steps to do are:

  1. Open the file in the “Macro Editor” by double click on the file in the GTuner IV “File Explorer”
  2. Hide unnecessary Inputs
    Click the button “Uncheck All” at the bottom-right, then click each checkbox of all the inputs you need for your combo only or the other way around: deselect the ones you don't need
  3. Select the section to export as a combo
    If you had multiple attemps to get the combo right or a long pause before or after your combo as you had to walk from your console to your pc you can now scroll to and select the part only you want to keep on via the graph in the macro recorder (left click at start and shift+left click at where you want to stop)
  4. Export
    Click the button “Convert macro or selection to GPC combo code”.
    It will be copied to your clipboard as a combo named “Macro2Combo”. Paste it into your .gpc script file.
  5. Optionally reduce the combo 10)
    Save some script space by removing lines that read set_val(GPC_Designator,0);
  6. Run the combo 11)
    Here is a basic script example to playback a combo one time when BUTTON_9 is pressed:
main {
    if (event_active(BUTTON_9)) combo_run(Macro2Combo);
}
1) Here is a more detailed tutorial about the Macro Editor Interface, created by prototype
2) More precisely up to 24 days, 20 hours, 31 minutes, 23 seconds and 650 milliseconds
3) The script size limitation does apply to combos so you can't convert long macros
4) 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
5) Dynamic changes to recorded inputs during playback, playback multiple actions at the same time,..
6) Optionally connected via Output to your console at the same time to do the inputs directly in the game
7) Or using any other supported input device/method
8) You can already filter the inputs to store in the macro by selecting a “File type” like Macro File (*.gmk) BUTTON when you only need the button actions
9) Editings like delete leading or trailing time without inputs, remove/add specific buttons/controls. Here is a more detailed tutorial about the Macro Editor Interface, created by prototype
10) For more details read Combos Pitfalls
11) For more details read Combos
t2/gpc_scripting/macros.1556366490.txt.gz · Last modified: 2019/04/27 08:01 by scachi