Init Section

The initialization or init section of a GPC is identical to the main section other than it is not run in a loop. The init section is run once before the first iteration of the main section when a script is first loaded and can run any combo or call any function. You can even modify the value of variables within it, just as you would in the main section.

The init section is used to setup your script. For example, say you wished to use the same Rapid Fire script on a PlayStation 3 and Xbox One but your PlayStation 3 game uses the bumper to shoot where as your Xbox One game uses the trigger, you could use the init section to automatically adjust your script on when it is loaded as shown in the following example;

int FIRE_BTN;
 
init {
 
    if(get_console() == PIO_PS3) {  //If connected to a PS3 when loaded
        FIRE_BTN = 3;   //3 = LB/L1
    } else {                        //If connected to any other console
        FIRE_BTN = 4;   //4 = RT/R1
    }
 
}
 
main {
 
    if(get_val(FIRE_BTN)) {
        combo_run(Rapid_Fire);
    }
 
}
 
combo Rapid_Fire {
    set_val(FIRE_BTN, 100);
    wait(50);
    set_val(FIRE_BTN, 0);
    wait(40);
    set_val(FIRE_BTN, 0);
}

The init section is very useful when you are using persistent variables as you do not want to constantly recall the values stored in them during run time. Information on Persistent Variables and how they can be recalled in the init section can be found here.

Last updated