Jump to content
Sign in to follow this  
hmihalis1

Set value of parameter based on value of switch

Recommended Posts

Hi,

I want to set the value of a parameter based on the value of a switch node, so if switch is 0 set the parameter to 1, if its 1 set the parameter to 10. Could anyone help with this?

currently I am trying

if((ch("../switch1/input")=0,1,10)

could anyone tell me where im going wrong?

thanks

Edited by hmihalis1

Share this post


Link to post
Share on other sites

is it what you want ?
val = ch("../switch1/input") ? 1 : 10;

but if you are not comfortable with vex it's more simple and readable to write :

if(ch("../switch1/input") == 0){
  val = 1;
}else{
  val = 10;
}

 

Share this post


Link to post
Share on other sites

you have parenteses mismatch, but most importantly you need to use == for equals 

if(ch("../switch1/input")==0,1,10)

  also this would work 

if(ch("../switch1/input"),10,1)

 

Edited by anim

Share this post


Link to post
Share on other sites

I've never seen this syntax

is this the  "ch("../switch1/input") ? 1 : 10;"  equivalent in expressions ?

Share this post


Link to post
Share on other sites
16 hours ago, flcc said:

I've never seen this syntax

is this the  "ch("../switch1/input") ? 1 : 10;"  equivalent in expressions ?

Yes, it's hscript, simply different language and therefore different syntax from VEX

Share this post


Link to post
Share on other sites

Ah, so much for me, I was the one who was uncomfortable here. haha

Thanks, thomas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×