What's wrong with my if statement?
10 posts • Page 1 of 1
What's wrong with my if statement?
(e)=>{{e.other.controllerAcc == 4.3}(?)(e.this.color = [1, 1, 1, 1])(:)(e.other.density = 1)}
What the hell is wrong with this onCollide code? I get no error messages or anything. It just doesn't execute. I can't figure out what I'm doing wrong here, and it's very frustrating.
What the hell is wrong with this onCollide code? I get no error messages or anything. It just doesn't execute. I can't figure out what I'm doing wrong here, and it's very frustrating.
Made some cool stuff a long time ago
-
Frank - [Best Tutorial Maker 2010]
- Posts: 193
- Joined: Mon Aug 31, 2009 6:37 pm
- Location: the dark side of the moon
Re: What's wrong with my if statement?
Well, your first problem is that it's not an if statement. What you've got there is a ternary conditional operator.
Aside from that, I have no idea.
And welcome back to the boards Frank!
Aside from that, I have no idea.
And welcome back to the boards Frank!
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.
a Mammoth wrote:be boring and interesting.
I didn't know you could go up 3.1.3! Thanks Mystery person!Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
-
Dakta - Posts: 417
- Joined: Sat Sep 12, 2009 4:36 pm
Re: What's wrong with my if statement?
Frank wrote:(e)=>{{e.other.controllerAcc == 4.3}(?)(e.this.color = [1, 1, 1, 1])(:)(e.other.density = 1)}
What the hell is wrong with this onCollide code? I get no error messages or anything. It just doesn't execute. I can't figure out what I'm doing wrong here, and it's very frustrating.
{e.other.controllerAcc == 4.3 ? {e.this.color = [1, 1, 1, 1]} : {e.other.density = 1}}
will work fine.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: What's wrong with my if statement?
@frank Did you place the brackets around the ? and : or was it algodoo ?
<- Designed by PhysicsGuy
-
xplane80 - Posts: 498
- Joined: Mon Aug 31, 2009 7:28 pm
Re: What's wrong with my if statement?
Algodoo did that.
Thanks Killinich, your script works. I can't figure out what I was doing wrong because I'm pretty sure I started with that, but now it works now and I can continue with my project.
Thanks Killinich, your script works. I can't figure out what I was doing wrong because I'm pretty sure I started with that, but now it works now and I can continue with my project.
Made some cool stuff a long time ago
-
Frank - [Best Tutorial Maker 2010]
- Posts: 193
- Joined: Mon Aug 31, 2009 6:37 pm
- Location: the dark side of the moon
Re: What's wrong with my if statement?
Frank, I think the original problem was the parens around the then/else sections, instead of curly braces.
- Code: Select all
{if} ? (then) : (else)
- Code: Select all
(if) ? {then} : {else}
- daniels220
- Posts: 95
- Joined: Mon Aug 31, 2009 11:30 pm
Re: What's wrong with my if statement?
Daniel, its always done that.
-
Mystery - Posts: 2802
- Joined: Thu Sep 03, 2009 1:16 pm
- Location: Southern Australia
Re: What's wrong with my if statement?
hey i know it:
(e)=>{your statement == SOMETHING ? {if it is} : {if it is NOT}}
so: (e)=>{ speed1 == speed2 ? {speed1 = speed2} : {speed1 = 10 (for example!!!) }
^^
''=='' can be: == (eaven)
>= (bigger than)
<= (smaller than)
(e)=>{your statement == SOMETHING ? {if it is} : {if it is NOT}}
so: (e)=>{ speed1 == speed2 ? {speed1 = speed2} : {speed1 = 10 (for example!!!) }
^^
''=='' can be: == (eaven)
>= (bigger than)
<= (smaller than)
- jessebax129
- Posts: 34
- Joined: Tue Jan 05, 2010 6:32 pm
Re: What's wrong with my if statement?
Well your kind of right, but also horribly wrong.
== Equal To
> More then
< Less then
>= Equal to or More then
<= Equal to or less then
!= Not Equal to
{If}?{Then}:{Else}
If i go to the mall, Then i'll buy shoes or Else i go barefoot
== Equal To
> More then
< Less then
>= Equal to or More then
<= Equal to or less then
!= Not Equal to
{If}?{Then}:{Else}
If i go to the mall, Then i'll buy shoes or Else i go barefoot
-
Mystery - Posts: 2802
- Joined: Thu Sep 03, 2009 1:16 pm
- Location: Southern Australia
Re: What's wrong with my if statement?
But it's not an if statement!
It's more like if conditional evaluates to true ? execute this code : otherwise execute this code
There is a difference you know. And I do have an open suggestion ticket for real if statements, or at least better elseif statements
It's more like if conditional evaluates to true ? execute this code : otherwise execute this code
There is a difference you know. And I do have an open suggestion ticket for real if statements, or at least better elseif statements
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.
a Mammoth wrote:be boring and interesting.
I didn't know you could go up 3.1.3! Thanks Mystery person!Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
-
Dakta - Posts: 417
- Joined: Sat Sep 12, 2009 4:36 pm
10 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests