Help make this script loop for (x) amount of time, ASAP!

GPC1 script programming for Titan One. Code examples, questions, requests.

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sat Mar 27, 2021 11:23 pm

Scachi wrote:you are breaking the time tracking for minutes that way but as long as you don't use the minutes you don't need to count them at all, same for hours and days..
so that may work for you:
Code: Select all
 
msecs = msecs + get_rtime();
    if(msecs >= 1000) {
        msecs = msecs - 1000;
        secs = secs + 1;
    }


but here is a maximum limit to that "secs" variable
it s valid range is limited to −32,768 to 32,767
as long as you don't need more than 32767 seconds to track you are fine with the above few lines of code.

there are always multiple ways to solve something.


Ah right okay! Thanks for explaining that!

So you're saying that it's possible to set that - and +600 to −32,768 to 32,767 if I wanted to? Like this?

Code: Select all
main {
    msecs = msecs + get_rtime();
    if(msecs >= 1000) {
        msecs = msecs - 1000;
        secs = secs + 1;
        if(secs >= 32767) {
            secs = secs - 32768;
            mins = mins + 1;
            if(mins >= 60) {
                mins = mins - 60;
                hours = hours + 1;
                if(hours >= 24) {
                    hours = hours - 24;
                    days = days + 1;
                }
            }
        }
    }


So this is basically saying that there's 32767 seconds in a minute?
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sat Mar 27, 2021 11:25 pm

Scachi wrote:something like that:
if (mins*60 + secs < 153) combo_run(SMASH_X);


Also, I decided to use this method. What exactly is it saying? Like, mins*60?
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Scachi » Sun Mar 28, 2021 12:07 am

Ctuna2000 wrote:
Scachi wrote:something like that:
if (mins*60 + secs < 153) combo_run(SMASH_X);


Also, I decided to use this method. What exactly is it saying? Like, mins*60?

just like a clock works with its values...
A minute has 60 seconds , so I convert the minutes counted back to seconds, add the counted seconds to it for being able to check if the total of seconds has reached your limit of 153 seconds
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sun Mar 28, 2021 12:39 am

Scachi wrote:
Ctuna2000 wrote:
Scachi wrote:something like that:
if (mins*60 + secs < 153) combo_run(SMASH_X);


Also, I decided to use this method. What exactly is it saying? Like, mins*60?

just like a clock works with its values...
A minute has 60 seconds , so I convert the minutes counted back to seconds, add the counted seconds to it for being able to check if the total of seconds has reached your limit of 153 seconds


Ah okay, thanks for letting me know!

Also, can you put this in this script please? I want it to run throughout.

Code: Select all
 combo SMASH_W {
set_val(XB1_LX, 0);
set_val(XB1_LY, 0);
}


Code: Select all
int SMASH = FALSE;
 
int msecs, secs, mins, hours, days;
 
main {
    msecs = msecs + get_rtime();
    if(msecs >= 1000) {
        msecs = msecs - 1000;
        secs = secs + 1;
        if(secs >= 60) {
            secs = secs - 60;
            mins = mins + 1;
            if(mins >= 60) {
                mins = mins - 60;
                hours = hours + 1;
                if(hours >= 24) {
                    hours = hours - 24;
                    days = days + 1;
                }
            }
        }
    }
 
    if(event_press(XB1_DOWN)) {
        SMASH = !SMASH;
        msecs = 0; secs = 0; mins = 0; hours = 0; days = 0;
    }
 
    if (SMASH) {
        if (mins*60 + secs < 153) combo_run(SMASH_X);
        else {
            combo_stop(SMASH_X);
            combo_run(SMASH_Y);
        }
    }
 
}
 
 
combo SMASH_X {
set_val(XB1_RT,100);
set_val(XB1_A, 100);
wait(110);
set_val(XB1_RT,100);
set_val(XB1_A, 0);
wait(110);
set_val(XB1_RT,100);
}
 
combo SMASH_Y {
wait(4000);
wait(4000);
set_val(XB1_X,100)
wait(110);
msecs = 0; secs = 0; mins = 0; hours = 0; days = 0;
}
 
 
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Scachi » Sun Mar 28, 2021 5:25 am

That isn't hard to do yourself. you should be able to figure it out by looking at your current code and/or reading that page:
https://www.consoletuner.com/kbase/comb ... s=AgAAAAE=

if you want the combo to run all the time when the script is toggled on "if (SMASH) {"
then put that "combo_run(SMASH_W);" line in that section of your code.

a wait(10); at the end of that combo may be required for it to really block the stick..again.. I don't have a T1 so I can't say for sure.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sun Mar 28, 2021 2:23 pm

Scachi wrote:That isn't hard to do yourself. you should be able to figure it out by looking at your current code and/or reading that page:
https://www.consoletuner.com/kbase/comb ... s=AgAAAAE=

if you want the combo to run all the time when the script is toggled on "if (SMASH) {"
then put that "combo_run(SMASH_W);" line in that section of your code.

a wait(10); at the end of that combo may be required for it to really block the stick..again.. I don't have a T1 so I can't say for sure.


Well, true, it's pretty basic, it was late last night and yeah lol.

Anyways, thanks for all of your help in this thread, appreciate it!
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sun Mar 28, 2021 2:42 pm

Scachi wrote:That isn't hard to do yourself. you should be able to figure it out by looking at your current code and/or reading that page:
https://www.consoletuner.com/kbase/comb ... s=AgAAAAE=

if you want the combo to run all the time when the script is toggled on "if (SMASH) {"
then put that "combo_run(SMASH_W);" line in that section of your code.

a wait(10); at the end of that combo may be required for it to really block the stick..again.. I don't have a T1 so I can't say for sure.


Also, for the line where it says "if (SMASH) {", does the code just know that I'm talking about the combos? "SMASH" isn't quite SMASH_X/SMASH_Y/SMASH_W.
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Scachi » Sun Mar 28, 2021 5:45 pm

Code: Select all
int SMASH = FALSE; 


SMASH is your "int" toggle variable at the top of your code.

here you switch it between 1 <-> 0:

Code: Select all
if(event_press(XB1_DOWN)) {
        SMASH = !SMASH;
        msecs = 0; secs = 0; mins = 0; hours = 0; days = 0;
    }
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Ctuna2000 » Sun Mar 28, 2021 6:09 pm

Scachi wrote:
Code: Select all
int SMASH = FALSE; 


SMASH is your "int" toggle variable at the top of your code.

here you switch it between 1 <-> 0:

Code: Select all
if(event_press(XB1_DOWN)) {
        SMASH = !SMASH;
        msecs = 0; secs = 0; mins = 0; hours = 0; days = 0;
    }


Ah right okay, so what does it mean when it goes to !SMASH?
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Help make this script loop for (x) amount of time, ASAP!

Postby Scachi » Sun Mar 28, 2021 6:23 pm

"here you switch between 1 <-> 0" ..
that SMASH = !SMASH; inverts the current value of SMASH . so when its 1 it gets set to 0, or the other way around.

Please read up some basic c programming tutorials , search them via google.
You can easily lookup that stuff on your own.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

PreviousNext

Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 114 guests