> 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/basic-syntax.md).

# Basic Syntax

GPC's syntax is heavily based on C. If you've ever written C, Java, or JavaScript, most of this will feel familiar right away.

```gpc
define cronus = 120;
int zen = 100;

main {
    if(get_val(XB1_A)) {
        combo_run(jump);
    }
}

combo jump {
    set_val(XB1_A, 100);
    wait(cronus);
    set_val(XB1_A, 0);
    wait(zen);
}
```

***

### Instruction Separation

As in C, GPC requires instructions to be terminated with a semicolon at the end of each statement. However, the closing tag of a block code automatically implies a semicolon, so a semicolon is not needed when terminating the last line of a GPC block.

```gpc
main {
    sensitivity(XB1_LY, NOT_USE, 80);
    a = b * (c + 20)
}
```

Although the semicolon is not required in the final line of a block, it is considered good practice to use one so it is not missed should you expand on the code at a later date.

***

### Nesting Code

Nesting code, or creating a logic block, binds code together. A block starts with a `{` and end with a `}`. What this does is nest the code with the `{` and `}` meaning that the code is only executed when the statement before it is active.

```gpc
main {                                    //main start
    if(get_val(PS4_R2)) {                 //block 1 start
        if(get_val(PS4_L2)) {             //block 2 start
            combo_run(rapid_fire_ads);
        }                                 //block 2 end
        else {                            //block 3 start
            combo_run(rapid_fire);
        }                                 //block 3 end
    }                                     //block 1 end
}                                         //main end
```

In this example, blocks 2 & 3 are ignored unless block 1 is active. So if the R2 button is not pressed, nothing happens. If R2 is pressed, then the Cronus Zen looks at block 2. If L2 is pressed, it will run the combo `rapid_fire_ads` and ignore block 3. However, if L2 is not pressed, it will ignore block 2 and instead execute the code in block 3 and then run combo `rapid_fire`.

Nesting is implied if you only have one line of code after a statement as in this example:

```gpc
main {
    if(get_val(XB1_RT) > 95)
        combo_run(rapid_fire);
}
```

When compiled, the line `combo_run(rapid_fire);` will automatically be nested within the `if` statement. If you wish for more than one line of code to only be executed when the statement before them is active, then you must use `{` and `}`.

***

### Commenting Code

A comment is text which is ignored by the compiler. Comments are usually used to annotate code for future reference or to add notes for others looking at the code. However, they can also be used to make certain lines of code inactive to aid when debugging scripts.

If you have programmed in C before then GPC comments will be familiar to you as it uses the same style. There are two types of comments, the single line comment and the multi line comment.

#### Single Line Comment

The `//` (two slashes) characters create a single line comment and can be followed by any sequence of characters. A new line terminates this form of comment as shown below:

```gpc
main {
    // a single line comment
    if(get_val(XB1_RT) > 95)    // another single line comment
        combo_run(rapid_fire);
}
```

#### Multi Line Comment

The `/*` (slash, asterisk) characters start a multi line comment and can also be followed by any sequence of characters. The multi line comment terminates when the first `*/` (asterisk, slash) is found as shown below:

```gpc
main {
    /*
        a multi line comment
        if(get_val(XB1_RT) > 95)
            combo_run(rapid_fire);
    */
}
```

As the comment terminates when a `*/` (asterisk, slash) is found, this style of commenting cannot be nested as shown below:

```gpc
main {
    /*
        a multi line comment
        if(get_val(XB1_RT) > 95)
            combo_run(rapid_fire);
        /*
            this will cause a problem
        */
    */
}
```


---

# 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/basic-syntax.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.
