How to run a combo based on time, eg. once every 60seconds

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

How to run a combo based on time, eg. once every 60seconds

Postby creedkiller » Thu Aug 23, 2018 12:48 pm

I'm guessing this can be done with get_rtime but I am unsure of the syntax
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: How to run a combo based on time, eg. once every 60secon

Postby Scachi » Thu Aug 23, 2018 1:05 pm

T1 or T2 ? Don't you own a T2 ?
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: How to run a combo based on time, eg. once every 60secon

Postby creedkiller » Thu Aug 23, 2018 3:41 pm

Scachi wrote:T1 or T2 ? Don't you own a T2 ?

I own both, but working on a script for a mate who only has the T1
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: How to run a combo based on time, eg. once every 60secon

Postby Scachi » Thu Aug 23, 2018 4:03 pm

GTuner pro has some nice code examples in the integrated help, but it is available online too:
https://www.consoletuner.com/kbase/misc ... #get_rtime
If you want to extecute something every 60 secs you can place the code below that line: if(secs >= 60) {
Code: Select all
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;
 
                }
 
            }
 
        }
 
    }
 
    set_val(TRACE_1, secs);
 
    set_val(TRACE_2, mins);
 
    set_val(TRACE_3, hours);
 
    set_val(TRACE_4, days);
 
}
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: How to run a combo based on time, eg. once every 60secon

Postby creedkiller » Thu Aug 23, 2018 5:07 pm

Scachi wrote:GTuner pro has some nice code examples in the integrated help, but it is available online too:
https://www.consoletuner.com/kbase/misc ... #get_rtime
If you want to extecute something every 60 secs you can place the code below that line: if(secs >= 60) {
Code: Select all
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;
 
                }
 
            }
 
        }
 
    }
 
    set_val(TRACE_1, secs);
 
    set_val(TRACE_2, mins);
 
    set_val(TRACE_3, hours);
 
    set_val(TRACE_4, days);
 
}

Nice one mate, thank you. :)
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: How to run a combo based on time, eg. once every 60secon

Postby creedkiller » Fri Aug 24, 2018 8:47 pm

Scachi wrote:GTuner pro has some nice code examples in the integrated help, but it is available online too:
https://www.consoletuner.com/kbase/misc ... #get_rtime
If you want to extecute something every 60 secs you can place the code below that line: if(secs >= 60) {
Code: Select all
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;
 
                }
 
            }
 
        }
 
    }
 
    set_val(TRACE_1, secs);
 
    set_val(TRACE_2, mins);
 
    set_val(TRACE_3, hours);
 
    set_val(TRACE_4, days);
 
}

Do you (or anyone else) know if overclocking the vm with vm_tctrl() changes get_rtime()?
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: How to run a combo based on time, eg. once every 60secon

Postby Scachi » Fri Aug 24, 2018 9:05 pm

I haven't tested it but it shouldn't matter. The docs states:
"Returns the elapsed time, in milliseconds, between the current and the previous interaction of the main procedure."
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: How to run a combo based on time, eg. once every 60secon

Postby creedkiller » Fri Aug 24, 2018 11:44 pm

Scachi wrote:I haven't tested it but it shouldn't matter. The docs states:
"Returns the elapsed time, in milliseconds, between the current and the previous interaction of the main procedure."

cheers for that, for my use it really doesnt matter if the 60 seconds is not accurate. I was just curious.
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: How to run a combo based on time, eg. once every 60secon

Postby J2Kbr » Mon Aug 27, 2018 9:16 am

creedkiller wrote:Do you (or anyone else) know if overclocking the vm with vm_tctrl() changes get_rtime()?

The get_rtime() returns the correct amount of milliseconds even if using vm_tctrl().
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 65 guests

cron