Cronus GPC Documentation
Cronus CommunityGPC LibraryGPC Guide
  • Welcome
  • Introduction
    • GPC Explained
    • What's New with Zen?
  • Basic Syntax
  • A Simple Tutorial
  • Style Guide
  • GPC Structure
  • Basic GPC Structure
  • Definitions
  • Data Section
  • Remapping
  • Variables
  • Init Section
  • Main Section
  • Combo Section
  • User Created Functions
  • GPC Programming Basics
  • Constants
    • Zen
      • OLED
      • ASCII Constants
      • PIO
    • Keyboard
      • Keyboard
    • Controller
      • Polar
      • LED
      • Rumble
      • PS3
      • PS4
      • XBox 360
      • Xbox One
      • Nintendo WII
      • Nintendo Switch
    • Racing Wheel
      • G29
      • G27
      • G25
      • DF
      • DF GT
      • DF Pro
    • Trace
    • Memory
    • Misc
  • Flow Control
  • Persistent Memory
  • Operator Types
  • Identifiers
  • Functions & Commands
    • Internal Functions
      • Bit Functions
      • Combo Functions
      • Math Functions
      • Device Functions
      • OLED Display Functions
    • Console Functions
      • Core Console Functions
    • Controller Functions
      • Core Controller Functions
      • Rumble Functions
      • LED Functions
    • Keyboard Functions
      • Core Keyboard Functions
  • GPC Examples
    • #1
Powered by GitBook
On this page

Was this helpful?

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.

PreviousVariablesNextMain Section

Last updated 5 years ago

Was this helpful?