Declaration combo syntax error?

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

Declaration combo syntax error?

Postby Racing » Sat Oct 01, 2016 4:32 pm

Hi, I'm doing some combos, and at the end makes me syntax error, and not because it is. Thanks in advance.
Code: Select all
// Use the Xbox One controller on PS4
// View + Menu should active PS4 Touch click
// View triggers the PS4 Share button if held donw for more than half second
// And "Hair-Trigger" MOD
#include <xb1.gph> // for XB1
#include <ps4.gph> // for PS4

#define TRUE           !FALSE

bool inhibit_share = FALSE;

bool rapid_on = FALSE;
uint8 FIRE_HOLD_RAPID = 20;
uint8 FIRE_WAIT_RAPID = 20;
bool auto fire_on = FALSE
init {
   port_inhibit_ffb(PORT_USB_B);
}

main {
    if(get_val(XB1_P4)) {
        set_val(PS4_CIRCLE, 100);
        set_val(XB1_P4, 0);
    }
   
    if(get_val(XB1_P2)) {
        set_val(PS4_CROSS, 100);
        set_val(XB1_P2, 0);
    }
   
    if(get_val(XB1_VIEW)) {
        if(time_active(XB1_VIEW) < 1000 || inhibit_share) {
            set_val(XB1_VIEW, 0);
            if(get_val(XB1_MENU)) {
                inhibit_share = TRUE;
                set_val(XB1_MENU, 0);
                set_val(PS4_TOUCH, 100);
            }
        }
    } else inhibit_share = FALSE;

    if(get_val(XB1_LT)) {
        set_val(PS4_L2, 100);
    }
    if(get_val(XB1_RT)) {
        set_val(PS4_R2, 100);
    }
   
    // on / off rapid fire
    if(get_val(PS4_L2) && is_active(PS4_UP)) rapid_on = TRUE;
    else if(get_val(PS4_L2) && is_active(PS4_DOWN)) rapid_on = FALSE;
    // or the one below to toggle on/off with hold L2 + press up (remove the two above then)
    //if(get_val(PS4_L2) && event_active(PS4_UP)) rapid_on = !rapid_on;
   
    // on / off RapidMid Fire
    if (get_val(PS4_L2) && is active (PS4_RIGHT)) RapidMid fire_on = TRUE;
    else if (get_val(PS4_L2) && is_active (PS4_DOWN) RapidMid fire_on = FALSE;
   
    //on / off Rapidslow fire
    if (get_val (PS4_L2) && is active (PS4_LEFT) Rapidslow fire_on= TRUE
    else if (get_val (PS4_L2) &&is_active (PS4_DOWN) RapidSlow fire_on= FALSE
   
    // use rapid fire
   if (get_val(PS4_R2) && rapid_on) combo_run(RapidFire);
   
    //use RapidMid Fire
    if (get_val (PS4_R2) && RapidMid fire_on) combo_run (RapidMidFire);
   
    //use Rapisslow fire
    if (get_val (PS4_R2) && RapidSlow fire_on) combo_run (rapidslowdire);
}

// rapid fire
combo RapidFire {
   set_val(PS4_R2, 100);
   wait(FIRE_HOLD_RAPID);
   set_val(PS4_R2, 0);
   wait(FIRE_WAIT_RAPID);
   set_val(PS4_R2, 0);
}
// Rapid Mid Fire
combo RapidMidFire (
    set_val (PS4_R2, 100);
    wait (100)
    set_val (PS4_R2) 0);
    wait (30);
    set_val (PS4_R2, 0);
)
// Rapid Slow Fire
combo Rapidslowfire
    set_val (PS4_R2,100);
    wait (150)
    set_val (PS4_R2, 0)
    wait (140)
    set_val(PS4_R2,0)
User avatar
Racing
Sergeant Major
Sergeant Major
 
Posts: 106
Joined: Thu May 26, 2016 4:18 pm

Re: Declaration combo syntax error?

Postby Scachi » Sat Oct 01, 2016 6:10 pm

You have a pm with some more details...

You are missing a couple of ) and ; and having whitespace between the functions and the opening ( at some positions.
And perhaps a logical error. It looks like you are activating all rapid fire modes at the same time and using them at the same time too.

Here is the corrected code, but it still contains the logical error.

Code: Select all
// Use the Xbox One controller on PS4
// View + Menu should active PS4 Touch click
// View triggers the PS4 Share button if held donw for more than half second
// And "Hair-Trigger" MOD
#include <xb1.gph> // for XB1
#include <ps4.gph> // for PS4

#define TRUE           !FALSE

bool inhibit_share = FALSE;

bool rapid_on = FALSE;
bool RapidMid = FALSE;
bool RapidSlow = FALSE;
uint8 FIRE_HOLD_RAPID = 20;
uint8 FIRE_WAIT_RAPID = 20;
bool auto_fire_on = FALSE;

init {
 port_inhibit_ffb(PORT_USB_B);
}

main {
 
  if(get_val(XB1_P4)) {
        set_val(PS4_CIRCLE, 100);
        set_val(XB1_P4, 0);
  }
 
  if(get_val(XB1_P2)) {
        set_val(PS4_CROSS, 100);
        set_val(XB1_P2, 0);
  }
 
  if(get_val(XB1_VIEW)) {
        if(time_active(XB1_VIEW) < 1000 || inhibit_share) {
             set_val(XB1_VIEW, 0);
             if(get_val(XB1_MENU)) {
                  inhibit_share = TRUE;
                  set_val(XB1_MENU, 0);
                  set_val(PS4_TOUCH, 100);
             }
        }
  } else inhibit_share = FALSE;

  if(get_val(XB1_LT)) {
        set_val(PS4_L2, 100);
  }
  if(get_val(XB1_RT)) {
        set_val(PS4_R2, 100);
  }
 
 
 
  // on / off rapid fire
  if(get_val(PS4_L2) && is_active(PS4_UP)) rapid_on = TRUE;
  else if(get_val(PS4_L2) && is_active(PS4_DOWN)) rapid_on = FALSE;
  // or the one below to toggle on/off with hold L2 + press up (remove the two above then)
  //if(get_val(PS4_L2) && event_active(PS4_UP)) rapid_on = !rapid_on;

 // on / off RapidMid Fire
if (get_val(PS4_L2) && is_active(PS4_RIGHT)) RapidMid = TRUE;
 else if (get_val(PS4_L2) && is_active(PS4_DOWN)) RapidMid = FALSE;
 
 //on / off Rapidslow fire
if (get_val (PS4_L2) && is_active(PS4_LEFT)) RapidSlow = TRUE;
 else if (get_val (PS4_L2) &&is_active(PS4_DOWN)) RapidSlow = FALSE;
 
  // use rapid fire
if (get_val(PS4_R2) && rapid_on) combo_run(RapidFire);
 
 //use RapidMid Fire
if (get_val (PS4_R2) && RapidMid) combo_run(RapidMidFire);
 
 //use Rapisslow fire
if (get_val (PS4_R2) && RapidSlow) combo_run(Rapidslowfire);
 
}


// rapid fire
combo RapidFire {
 set_val(PS4_R2, 100);
 wait(FIRE_HOLD_RAPID);
 set_val(PS4_R2, 0);
 wait(FIRE_WAIT_RAPID);
 set_val(PS4_R2, 0);
}
// Rapid Mid Fire
combo RapidMidFire {
 set_val(PS4_R2, 100);
 wait(100);
 set_val(PS4_R2, 0);
 wait(30);
 set_val (PS4_R2, 0);
}
// Rapid Slow Fire
combo Rapidslowfire {
 set_val(PS4_R2,100);
 wait(150);
 set_val(PS4_R2, 0);
 wait (140);
 set_val(PS4_R2,0);
}
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 45 guests