Assigning Multiple Buttons to Variables
2 posts
• Page 1 of 1
Assigning Multiple Buttons to Variables
I feel like I'm missing a simple way to assign combined button presses to singular variables...
But as an int, DOUBLE only points to single buttons and goes awry if I try to assign multiples. This leads to way more lines to achieve the above:
Method 3 - https://www.consoletuner.com/kbase/vari ... arrays.htm - also fails to combine because we're still using an int:
Any ideas?!
- Code: Select all
#define R1 BUTTON_4
#define A BUTTON_17
#define B BUTTON_14
#define C BUTTON_15
int DOUBLE;
fix32 RNG;
main {
if(event_active(R1)) combo_run(COMBO);
if(RNG < 0.50) DOUBLE = A;
else DOUBLE = B && C;
}
combo COMBO {
RNG = rand();
set_val(DOUBLE, 100);
printf("DOUBLE is %p", DOUBLE);
wait(100);
}
But as an int, DOUBLE only points to single buttons and goes awry if I try to assign multiples. This leads to way more lines to achieve the above:
- Code: Select all
#define R1 BUTTON_4
#define A BUTTON_17
#define B BUTTON_14
#define C BUTTON_15
int ON1;
int ON2;
fix32 RNG;
main {
if(event_active(R1)) combo_run(COMBO);
if(RNG < 0.50) {
ON1 = 100;
ON2 = 0;
}
else if(RNG >= 0.50) {
ON1 = 0;
ON2 = 100;
}
}
combo COMBO {
RNG = rand();
set_val(A, ON1);
set_val(B, ON2);
set_val(C, ON2);
printf("ON1 is %d - ON2 is %d", ON1, ON2);
wait(100);
}
Method 3 - https://www.consoletuner.com/kbase/vari ... arrays.htm - also fails to combine because we're still using an int:
- Code: Select all
#define R1 BUTTON_4
#define A BUTTON_17
#define B BUTTON_14
#define C BUTTON_15
int a = A, b = B, c = C, DOUBLE;
fix32 RNG;
main {
if(event_active(R1)) combo_run(COMBO);
if(RNG < 0.50) a[3] = a[0];
else a[3] = a[1] + a[2];
}
combo COMBO {
RNG = rand();
set_val(DOUBLE, 100);
printf("DOUBLE is %p", DOUBLE);
wait(100);
}
Any ideas?!
-
Glooper - Sergeant First Class
- Posts: 19
- Joined: Sun May 15, 2016 2:33 am
Re: Assigning Multiple Buttons to Variables
The second script is the correct way having three set_vals.
set_val only takes one button index and then the value.
https://www.consoletuner.com/wiki/index ... t2:set_val
set_val only takes one button index and then the value.
https://www.consoletuner.com/wiki/index ... t2:set_val
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 84 guests