Question about Get_Val for Acceleration

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

Question about Get_Val for Acceleration

Postby atwerkingyoshi » Sat Oct 19, 2019 9:06 pm

Hey everyone!

Just picked up the titan two and loving it so far however I had a question about using data from get_val. Right now I'm trying to use the JoyCon's acceleration/gyro by using get_val however I received an error.

Code: Select all
 
main
{
// movement based running using red joycon on leg strap
if(get_val(ACCEL_1_Y) > 30)
    {
        set_val(STICK_1_Y, 100);
    }
}
 


error received:
Code: Select all
GPC error: joycon_Workout.gpc(37): Illegal operation '>'. 


I could be mis-remembering but I thought I was able to do this with the wiimote on the TitanOne using get_val(WII_ACCX) without an issue. What am I doing wrong in this case?
Thanks ahead of time!
User avatar
atwerkingyoshi
Private First Class
Private First Class
 
Posts: 2
Joined: Sun Oct 15, 2017 5:27 pm

Re: Question about Get_Val for Acceleration

Postby Scachi » Sat Oct 19, 2019 10:04 pm

get_val returns a "fix32" value now on the T2.
add .0 to you comparing number:
Code: Select all
 
main
{
// movement based running using red joycon on leg strap
if(get_val(ACCEL_1_Y) > 30.0)
    {
        set_val(STICK_1_Y, 100); // set_val can handle int or decimal as this works too: set_val(STICK_1_Y, 100.0);
    }
}
 

wiki : scripting : data types
wiki : scripting : gpc language reference explained
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Question about Get_Val for Acceleration

Postby atwerkingyoshi » Sat Oct 19, 2019 10:26 pm

Ohhh that makes sense now. Completely forgot about the data types.

Thank you very much!
User avatar
atwerkingyoshi
Private First Class
Private First Class
 
Posts: 2
Joined: Sun Oct 15, 2017 5:27 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 148 guests