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 10:01 pm

Scachi wrote:that last wait was meant to make sure that it really runs the last code before exiting the combo.. there were issues at some time when the combo may not execute the last lines when they do not have a wait following. not sure if this was a bug that got fixed or only happens on specific cases.

the T1 runs at 10ms interval by default
so "msecs = msecs + get_rtime();" will add 10ms per each run
when you check for less then 10ms that time limit may also be reached at the start of the code or after one cycle before your combo is able to press any buttons.


Okay, thanks for the explanation! So even though I took out the last line, would I still have to do something about the 10ms?


So, I edited my last message, how come I can't set the seconds for something random like 153 seconds?
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 » Sat Mar 27, 2021 10:34 pm

seconds will only be in the range of 0 .. 50ms under normal circumstances in that code:
secs = secs + 1;
if(secs >= 60) {
secs = secs - 60;
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 » Sat Mar 27, 2021 10:36 pm

Scachi wrote:seconds will only be in the range of 0 .. 50ms under normal circumstances in that code:
secs = secs + 1;
if(secs >= 60) {
secs = secs - 60;


I don't really understand what you're saying? So how can I set it for 153 seconds?


Also, how come I can't set negative wait times like -10ms or something. It errors.
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 » Sat Mar 27, 2021 10:41 pm

there are limits to functions because of how the functions are designed...
what should a negative wait time do ?
wait(-10) ? ...that makes no sense.

wait repeats the lines in the combo above that wait line for that amount of ms of the value of that wait time.
so :
set_val(PS4_CIRCLE,100);
wait(100);
will press the circle button for 100ms...
what should pressing a button for -10ms do ?

that time function is math..
when the secs value gets to 60 ir get reduced by -60 and the mins values gets increased by 1..
60 seconds gets 1 minute.. there is no 70 seconds in that code..no secs 70 value possible during normal run.
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 » Sat Mar 27, 2021 10:48 pm

Scachi wrote:Ok, right. the T1 has a 10ms minimum.

try without the last wait, remove it , check if its still works correctly.

or you can try setting that secs to -10 instead of 0 to compensate for the 10ms.


Well, you said that I can set it to -10 here.


Scachi wrote:there are limits to functions because of how the functions are designed...
what should a negative wait time do ?
wait(-10) ? ...that makes no sense.

wait repeats the lines in the combo above that wait line for that amount of ms of the value of that wait time.
so :
set_val(PS4_CIRCLE,100);
wait(100);
will press the circle button for 100ms...
what should pressing a button for -10ms do ?

that time function is math..
when the secs value gets to 60 ir get reduced by -60 and the mins values gets increased by 1..
60 seconds gets 1 minute.. there is no 70 seconds in that code..no secs 70 value possible during normal run.



Wait, I thought this was a wait time? Like, how long the first combo would loop for?
Code: Select all
 if (mins < 7) combo_run(SMASH_X);


I see what ur saying about that function being the math of the script.
How can I set it to loop the first combo for an odd time like 153 seconds?


I was hoping that a negative wait time could be in place to make it a few seconds under 7 minutes.
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 » Sat Mar 27, 2021 10:57 pm

ok.. sorry.. I though you talked about the wait() stuff
well 153 seconds .. translate it to minutes and seconds and check for that in the if statement
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 » Sat Mar 27, 2021 10:59 pm

Scachi wrote:ok.. sorry.. I though you talked about the wait() stuff
well 153 seconds .. translate it to minutes and seconds and check for that in the if statement


Okay I see, how do I do that?
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 » Sat Mar 27, 2021 11:00 pm

something like that:
if (mins*60 + secs < 153) combo_run(SMASH_X);
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 » Sat Mar 27, 2021 11:05 pm

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


Hmmm okay. So while I was typing, I just set the seconds bit to + and + 600. (So I can select any number between 0 and 600?)

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


It seems to work, but have I just messed up a function of the script? Like, would it just break or something? I don't really understand what I've done lol.
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 » Sat Mar 27, 2021 11:11 pm

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.
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 44 guests