---
title: Init Section
slug: gpc/gpc-scripting-init-section
description: 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 f
docTags: 
createdAt: 2022-02-05T14:40:38.000Z
---

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.&#x20;
The init section is used to set up your script.

For example, say you wished to use the same Rapid Fire script on a PlayStation 4 and Xbox One but your PlayStation 4 game uses the bumper to shoot whereas 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;&#x20;

:::CodeblockTabs
GPC

```cpp
int FIRE_BTN;
 
init {
 
    if(get_console() == PIO_PS4) {  //If connected to a PS4 when loaded
        FIRE_BTN = PS4_R1;
    } else {                        //If connected to any other console
        FIRE_BTN = XB1_RT;
    }
 
}
 
main {
 
     if(get_ival(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 in the [Persistent Memory](docId\:fo9M72-7rvVzdkGS9uyde) section
