Jump to content

attribute not defined correctly


Blacklisted_Guy

Recommended Posts

I started working on some vex practice and decided to use it for a switch and a bunch of statements

I've wrote this script  but the second if statement (rot =1 && flip = 0) doesn't seem to be giving the right value.
 

int rotatetion= ch("rot");
int flipvalue= ch("flip");
@switch = 0;

if ( (rotatetion == 0) && (flipvalue == 0)) {
    @switch = 1;
}
if ( (rotatetion == 1) && (flipvalue == 0)) {
    @switch = 1;
}
if ( (rotatetion == 0) && (flipvalue == 1)) {
    @switch = 0;
}
if ( (rotatetion == 1) && (flipvalue = 1)) {
    @switch = 0;
}

rot and flip are integer sliders on the attribute wrangle node itself.

Link to comment
Share on other sites

for integer, use chi() rather than ch()

Similarly, you should probably defined your switch attribute as an integer: i@switch

Edit: should have tested it before, it does not fix your problem. However adding some else statements works:
 

int rotatetion= chi("rot");
int flipvalue= chi("flip");

i@switch = 0;

if ( (rotatetion == 0) && (flipvalue == 0) ) {
    @switch = 1;
}
else {
    if ( (rotatetion == 1) && (flipvalue == 0) ) {
        @switch = 1;
    }
    else {
        if ( (rotatetion == 0) && (flipvalue == 1) ) {
            @switch = 0;
        }
        if ( (rotatetion == 1) && (flipvalue = 1) ) {
            @switch = 0;
        }
    }
}

 

Edited by iamyog
  • Like 1
Link to comment
Share on other sites

48 minutes ago, iamyog said:

for integer, use chi() rather than ch()

Similarly, you should probably defined your switch attribute as an integer: i@switch

Edit: should have tested it before, it does not fix your problem. However adding some else statements works:
 


int rotatetion= chi("rot");
int flipvalue= chi("flip");

i@switch = 0;

if ( (rotatetion == 0) && (flipvalue == 0) ) {
    @switch = 1;
}
else {
    if ( (rotatetion == 1) && (flipvalue == 0) ) {
        @switch = 1;
    }
    else {
        if ( (rotatetion == 0) && (flipvalue == 1) ) {
            @switch = 0;
        }
        if ( (rotatetion == 1) && (flipvalue = 1) ) {
            @switch = 0;
        }
    }
}

 

that worked! Thank you so much

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...