website logo
Buy CronusGPC LibraryGamePacks (16bit)YouTubeForumsDiscord
📘Cronus Zen Guide
📗GamePacks (32bit)
📗GPC Script Guide
Navigate through spaces
📘Cronus Zen Guide
📗GamePacks (32bit)
📗GPC Script Guide
⌘K
📑GPC SCRIPTING
What's New in 32bit?
Introduction
Variables
Basic GPC Structure
Definitions
Data Section
Remapping
Const Arrays
Init Section
Main Section
Combo Section
User Created Functions
Identifiers
Flow Control
Constants
Functions
Device Functions
Remapping
Advanced Samples
API Samples
Docs powered by archbee 

A Simple Tutorial

Step 1

Load Zen Studio and click File > New > Empty File



Step 2

Copy and paste the following code into the GPC code editor within Zen Studio.

GPC
|


Step 3

Compile the code to check for errors. To do this, either press F7 on your keyboard or go to the Compiler drop-down menu in Zen Studio and select compile:



The Output window below the GPC editor should give you this message;

GPC
|


If your Cronus Zen is connected via the PROG USB port and you have a controller connected, you can see this script in action by using the Build and Run option. This is accessed by either pressing F5 or selecting Build and Run in the Compiler drop-down menu. This function will compile the code and then send it to your Cronus Zen so you can test it.



Script Breakdown

What this script does is run the combo named RAPID_FIRE whenever the right trigger has a value or is pressed. If the Right Trigger is still held when the combo ends, it will be run again. To analyze how the Cronus Zen is told how to do this we must first break the script down into its two sections, the main and combo sections.

The Main Section

GPC
|


As explained here, the main section is run in a loop by the Cronus Zen. The Virtual Machine in the Cronus Zen runs through the code in order and when it reaches the end of the code, data is sent to the console and then the Virtual Machine starts the next loop.

GPC
|


The above code tells the Cronus Zen that if the statement is TRUE, run the nested code. In this case, if XB1_RT (Right Trigger) has a value greater than 0 (Zero) so is pressed or not at rest.

GPC
|


Above is the code nested within the if statement. Nesting code creates a hierarchical structure. An open curly bracket ( { )starts the nesting and a closed curly bracket ( } ) ends it. By nesting code within the if statement we are telling the Cronus Zen that we only wish for that code to be executed only when the if statement is TRUE. More information on nesting code can be found here.

GPC
|


This line simply tells the Cronus Zen to run the combo named RAPID_FIRE. It is important to note that if the Cronus Zen receives this instruction and the combo is already running it will not do anything. It will only run the combo again if it has finished. This means that if you hold down the Right Trigger with this code active, the Cronus Zen start the combo and then run it again as soon as it has ended. Therefore running the combo in an indefinite loop or until such time as the Right Trigger is released.

The Combo Section

GPC
|


This is the combo that the Cronus Zen is instructed to run when the Right Trigger is pressed. When run, a combo runs through the code until it gets to a wait statement. The wait statement instructs combo to execute the commands above it for a set amount of time which is expressed in milliseconds.

GPC
|


These lines instruct the combo to set the value of the Right Trigger to 100 (or fully pressed) for 40 milliseconds.

GPC
|


Once the 40 milliseconds has passed, these lines instruct the combo to set the Right Trigger to 0 (Release) for 30 milliseconds. Additional detail on how a combo operates can be found here.

Expanding the Code

Now that you understand how this script works, we will make it more complex and change when the combo is run.

Look at this line in the main section:

GPC
|


and change it to:

GPC
|


By introducing && !get_val(XB1_LT) into the if statement we are telling the Cronus Zen to only run the combo if the Right Trigger has a value and the Left Trigger does not. && means 'and' in GPC and ! means not. So the if statement now reads 'if Right Trigger has a value and Left Trigger does not. This means when using this code in-game the Cronus Zen will only Rapid Fire your gun when you are not aiming down the sights. You can use the build and run function to see this code in action.

UP NEXT
Variables
Docs powered by archbee 
TABLE OF CONTENTS
Step 1
Step 2
Step 3
Script Breakdown
The Main Section
The Combo Section
Expanding the Code