Need To Run a Macro after X hours

GPC2 script programming for Titan Two. Code examples, questions, requests.

Need To Run a Macro after X hours

Postby Capo » Tue Nov 26, 2019 8:20 pm

Basically, I have this script:
Code: Select all
#pragma METAINFO("VC Generator (8).gpc", 1, 0, "Buffy's GPC Converter v0.26r4")
#include <titanone.gph>
 
 
// GPC Online Library
// gl0zz3n_nba_2k20_vc_generator.gpc
/*                             INSTRUCTIONS:
 
 
 
 
    WATCH THE DEMO: www.youtube.com/watch?v=2a-_Qos9rvs
 
 
 
 
    [1] Set Game Timer to 5-minute Quarters
    [2] Move cursor over the next game you want to play, so it is highlighted
    [3] Press the XBOX or PLAYSTATION button to start/stop the script.
 
    * When device LED is GREEN mod is ON.
    * When device LED is RED mod is OFF.
 
 
 
 
 
 
 
 
 
 
 
 
 
**/
//    set_val(TRACE_6,(times_run));
//set_val(TRACE_1,1);
//start Nest Game
//select "yes"
//select "yes"
//set_val(TRACE_1,2);
//set_val(TRACE_1,3);
//start Nest Game
//skip practice to next game
//start Nest Game
//select "yes"
//select "yes"
 
 
 // unmap 0;
 
int active;
int seconds = 65;
int times_run = 0;
 
 
main {
    if (event_press(0)) {
        seconds = 65;
        active =! active;
        combo_run(c_START_GAME);
        set_led(LED_1, 0);
        set_led(LED_2, 0);
        set_led(LED_3, 1);
    }
    if (!active) {
        set_led(LED_1, 0);
        set_led(LED_2, 1);
        set_led(LED_3, 0);
        combo_stop(c_START_GAME);
        combo_stop(c_GAME_TIMER);
        combo_stop(c_GAME_RESTART);
    }
    set_val(TRACE_2, (seconds));
}
 
 
combo c_START_GAME {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_Y, -100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    combo_run(c_GAME_TIMER);
}
 
combo c_GAME_TIMER {
    set_val(XB1_A, 100);
    wait(6000);
    wait(1500);
    set_val(XB1_B, 100);
    wait(75);
    wait(50);
    seconds = seconds - 1;
    if (seconds > 0) combo_run(c_BUMP);
    if (seconds < 1) combo_run(c_BUMP2);
}
 
combo c_BUMP {
    combo_run(c_GAME_TIMER);
}
 
combo c_BUMP2 {
    combo_run(c_GAME_RESTART);
}
 
combo c_GAME_RESTART {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_RIGHT, 100);
    wait(50);
    wait(500);
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_DOWN, 100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    seconds = 65;
    times_run = times_run + 1;
    combo_run(c_GAME_TIMER);
}
 
 
main { // remapping code
    set_val(0, 0);
}
 
 


and I want the script to run a macro after 7 hours and then run the combo c_Start_Game after that macro is done. how can I do that?
User avatar
Capo
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Oct 28, 2019 10:02 pm

Re: Need To Run a Macro after X hours

Postby DontAtMe » Tue Nov 26, 2019 10:07 pm

Capo wrote: I want the script to run a macro after 7 hours and then run the combo c_Start_Game after that macro is done. how can I do that?


Code: Select all
#include <xb1.gph>
 
uint32 timer;
bool macro_finished;
main {
 
  timer += elapsed_time();          /*  Wait 7 Hours  */
 
  if(timer < (((1000 * 60) * 60) * 7)) {
  // 1000 Miliseconds * 60 Seconds * 60 Minutes * 7 Hours.
    ...
  }
  else {                            /*  After 7 Hours  */
 
    if(macro_finished == FALSE){
      macro_run("urMacro.gmk");     /*  Run Macro  */
 
      if(macro_time() == 0) {
        macro_finished = TRUE;
      }
    }
    if(macro_finished == TRUE) {
      combo_run(c_Start_Game);      /*  When Macro Finished Run Combo  */
    }
  }
}
 
combo c_Start_Game  {               /*  Combo  */
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_Y, -100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
 
    timer = macro_finished = 0;     /*  Reset Script  */
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am

Re: Need To Run a Macro after X hours

Postby Capo » Wed Nov 27, 2019 3:42 pm

I need the whole script to run for 7 hours then run a macro and when that macro is over it restarts and the 7 hour timer begins again.
User avatar
Capo
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Oct 28, 2019 10:02 pm

Re: Need To Run a Macro after X hours

Postby Capo » Wed Nov 27, 2019 4:26 pm

It’s a farming script so I want the timer to begin once I start the script and then 7 hours later it plays a macro and after that macro runs the script starts up again and the timer resets back to 7 hours and counts down again
User avatar
Capo
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Oct 28, 2019 10:02 pm

Re: Need To Run a Macro after X hours

Postby DontAtMe » Wed Nov 27, 2019 4:36 pm

Capo wrote:I need the whole script to run for 7 hours then run a macro and when that macro is over it restarts and the 7 hour timer begins again.


Code: Select all
uint32 Timer;
main {
 
    Timer += elapsed_time();
 
    /*  Run script for 7 hours  */
 
  // 1000 Miliseconds * 60 Seconds * 60 Minutes * 7 Hours.
  if(Timer < (((1000 * 60) * 60) * 7)) {
    script(); //
  }
  else {
 
    /*  After 7 Hours Run Macro Then Reset Timer.  */   
 
    bool macro_finished;
    if(macro_finished == FALSE){
      macro_run("macro.gmk");
      if(macro_time() > 0) {
        macro_finished = TRUE;
      }
    }else if(macro_time() < 0){
      macro_finished = Timer = 0;
    }
  }
}
 
#include <titanone.gph>
int active;
int seconds = 65;
int times_run = 0;
 
void script() {
    if (event_press(0)) {
        seconds = 65;
        active =! active;
        combo_run(c_START_GAME);
        set_led(LED_1, 0);
        set_led(LED_2, 0);
        set_led(LED_3, 1);
    }
    if (!active) {
        set_led(LED_1, 0);
        set_led(LED_2, 1);
        set_led(LED_3, 0);
        combo_stop(c_START_GAME);
        combo_stop(c_GAME_TIMER);
        combo_stop(c_GAME_RESTART);
    }
    set_val(TRACE_2, (seconds));
}
 
 
combo c_START_GAME {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_Y, -100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    combo_run(c_GAME_TIMER);
}
 
combo c_GAME_TIMER {
    set_val(XB1_A, 100);
    wait(6000);
    wait(1500);
    set_val(XB1_B, 100);
    wait(75);
    wait(50);
    seconds = seconds - 1;
    if (seconds > 0) combo_run(c_BUMP);
    if (seconds < 1) combo_run(c_BUMP2);
}
 
combo c_BUMP {
    combo_run(c_GAME_TIMER);
}
 
combo c_BUMP2 {
    combo_run(c_GAME_RESTART);
}
 
combo c_GAME_RESTART {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_RIGHT, 100);
    wait(50);
    wait(500);
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_DOWN, 100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    seconds = 65;
    times_run = times_run + 1;
    combo_run(c_GAME_TIMER);
}
 
 
main { // remapping code
    set_val(0, 0);
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am

Re: Need To Run a Macro after X hours

Postby Capo » Sun Dec 01, 2019 5:23 am

DontAtMe wrote:
Capo wrote:I need the whole script to run for 7 hours then run a macro and when that macro is over it restarts and the 7 hour timer begins again.


Code: Select all
uint32 Timer;
main {
 
    Timer += elapsed_time();
 
    /*  Run script for 7 hours  */
 
  // 1000 Miliseconds * 60 Seconds * 60 Minutes * 7 Hours.
  if(Timer < (((1000 * 60) * 60) * 7)) {
    script(); //
  }
  else {
 
    /*  After 7 Hours Run Macro Then Reset Timer.  */   
 
    bool macro_finished;
    if(macro_finished == FALSE){
      macro_run("macro.gmk");
      if(macro_time() > 0) {
        macro_finished = TRUE;
      }
    }else if(macro_time() < 0){
      macro_finished = Timer = 0;
    }
  }
}
 
#include <titanone.gph>
int active;
int seconds = 65;
int times_run = 0;
 
void script() {
    if (event_press(0)) {
        seconds = 65;
        active =! active;
        combo_run(c_START_GAME);
        set_led(LED_1, 0);
        set_led(LED_2, 0);
        set_led(LED_3, 1);
    }
    if (!active) {
        set_led(LED_1, 0);
        set_led(LED_2, 1);
        set_led(LED_3, 0);
        combo_stop(c_START_GAME);
        combo_stop(c_GAME_TIMER);
        combo_stop(c_GAME_RESTART);
    }
    set_val(TRACE_2, (seconds));
}
 
 
combo c_START_GAME {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_Y, -100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    combo_run(c_GAME_TIMER);
}
 
combo c_GAME_TIMER {
    set_val(XB1_A, 100);
    wait(6000);
    wait(1500);
    set_val(XB1_B, 100);
    wait(75);
    wait(50);
    seconds = seconds - 1;
    if (seconds > 0) combo_run(c_BUMP);
    if (seconds < 1) combo_run(c_BUMP2);
}
 
combo c_BUMP {
    combo_run(c_GAME_TIMER);
}
 
combo c_BUMP2 {
    combo_run(c_GAME_RESTART);
}
 
combo c_GAME_RESTART {
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_RIGHT, 100);
    wait(50);
    wait(500);
    set_val(XB1_A, 100);
    wait(50);
    wait(500);
    set_val(XB1_DOWN, 100);
    wait(50);
    wait(200);
    set_val(XB1_A, 100);
    wait(50);
    wait(200);
    seconds = 65;
    times_run = times_run + 1;
    combo_run(c_GAME_TIMER);
}
 
 
main { // remapping code
    set_val(0, 0);
}

I was just able to try out this script and it works perfectly. Thank you
User avatar
Capo
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Oct 28, 2019 10:02 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 98 guests