Need help with loop for amount of times
2 posts
• Page 1 of 1
Need help with loop for amount of times
Script should work like this:
When pressing L3, run combo1 OR combo2 . Repeat this for 5-8 times, then stop.
So also randomly choose between the combos on every repeat.
for example if random repeat amount was 5, Output should look like:
Combo1
Combo1
Combo2
Combo1
Combo2
i tried for hours, sorry, have only little coding experience. at the moment both combos are triggered at the same time , and the number of repeats also doesnt seem to work.
would be perfect if your solution was scalable for adding more combos to this.
Thanks!
When pressing L3, run combo1 OR combo2 . Repeat this for 5-8 times, then stop.
So also randomly choose between the combos on every repeat.
for example if random repeat amount was 5, Output should look like:
Combo1
Combo1
Combo2
Combo1
Combo2
i tried for hours, sorry, have only little coding experience. at the moment both combos are triggered at the same time , and the number of repeats also doesnt seem to work.
would be perfect if your solution was scalable for adding more combos to this.
Thanks!
- Code: Select all
#define irand(a,b) (((int)(rand() * (fix32)(b+1 - a))) + a)
#include <PS4.gph>
int random,limit, count;
bool loop;
main {
if (event_active(PS4_L3)) {
count=0;
limit=irand(5,8);
loop=TRUE;}
if (count>limit) {loop=FALSE;}
//section A
if (loop) {
random=irand(1,2);
if (random==1)combo_run(combo1);
if (random==2)combo_run(combo2);}
}
combo combo1 {
set_val(PS4_R2,100);
wait(100);
set_val(PS4_R2, 0);
wait(100);
set_val(PS4_R2,100);
wait(100);
++count;}
combo combo2 {
set_val(PS4_L2,100);
wait(100);
set_val(PS4_L2, 0);
wait(100);
set_val(PS4_L2,100);
wait(100);
++count;}
-
A1rookie - Staff Sergeant
- Posts: 13
- Joined: Mon Sep 10, 2018 5:26 pm
Re: Need help with loop for amount of times
Hi i'm new to T2 coding i've tested it works fine just coppy it
- Code: Select all
#define irand(a,b) (((int)(rand() * (fix32)(b+1 - a))) + a)
#include <PS4.gph>
int random,limit, count;
bool loop;
main {
if (get_actual(BUTTON_9)) {
count=0;
limit=5;
loop=TRUE;}
if (count==4) {loop=FALSE;}
//section A
if (loop) {
random=irand(0,5);
if (random==1)combo_run(combo1);
if (random==2)combo_run(combo2);
}
}
combo combo1 {
set_val(BUTTON_5,100);
wait(100);
set_val(BUTTON_5, 0);
wait(100);
count++;
printf("R2 Pressed");
}
combo combo2 {
set_val(BUTTON_8,100);
wait(100);
set_val(BUTTON_8, 0);
wait(100);
count++;
printf("L2 Pressed");
}
-
Tahsin - Sergeant Major
- Posts: 100
- Joined: Wed May 15, 2019 7:57 am
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: oohmoi and 177 guests