Page 1 of 1

If/Then statement and DrawBorder

PostPosted: Mon Mar 04, 2019 9:29 pm
by TShrepel85

Just started writing script in this program in a pinball machine scene, and I'm having some trouble with an if/then statement working like it's supposed to. I have a set of 5 targets that I want to change states with DrawBorder and Restitution when the ball hits them. here's my code:

Code: Select all
    drawBorder == false ? {
        drawBorder = true;
        restitution = 3
    } : {
        drawBorder = false;
        restitution = 1
    points = points + 150

I've got this in the onCollide line of each of the targets, but it doesn't seem to want to do anything. The points line is a separate way I use to keep track of the player's points, and I've tried taking it out, still doesn't work. Any help y'all can give would be greatly appreciated. Thanks!

Re: If/Then statement and DrawBorder

PostPosted: Wed Mar 06, 2019 1:00 pm
by FRA32
Keep in mind that comparisons dont work with boolean(true/false) values, as they are obsolete. Since drawBorder is a boolean value, you can't compare it to another boolean as theres a way simpler method.
Instead of writing drawBorder == false, simply write !drawBorder ? {} : {}
An exclamation mark negates the following boolean value, so if it's true, it becomes false, and vice versa. Since if statements operate purely on boolean statements, you dont need any comparisons after that, the negated value itself is enough to set the condition.

Re: If/Then statement and DrawBorder

PostPosted: Thu Mar 07, 2019 11:22 pm
by TShrepel85
That's awesome! Thank you so much!