If/Then statement and DrawBorder
3 posts • Page 1 of 1
If/Then statement and DrawBorder
Hello!
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:
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!
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
(e)=>{
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!
- TShrepel85
- Posts: 7
- Joined: Mon Mar 04, 2019 9:00 pm
Re: If/Then statement and DrawBorder
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.
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.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: If/Then statement and DrawBorder
That's awesome! Thank you so much!
- TShrepel85
- Posts: 7
- Joined: Mon Mar 04, 2019 9:00 pm
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests