> For the complete documentation index, see [llms.txt](https://guide.cronuszen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.cronuszen.com/gpcscripting/gpc-script-guide/gpc-developer-guide/init-section.md).

# 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 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:

```gpc
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 [Functions](/gpcscripting/gpc-script-guide/gpc-developer-guide/functions.md) section.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.cronuszen.com/gpcscripting/gpc-script-guide/gpc-developer-guide/init-section.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
