Lazor cutter/vaporizor w/ custom variables
9 posts • Page 1 of 1
Lazor cutter/vaporizor w/ custom variables
I'm making a pulse rifle, it's got 2 functions- 1 is cut, other is vaporize.
i have a custom boolean variable IN the lazor called vaporize.
in my onLaserHit, I have this:
Why is this not working?
It won't ever vaporize an object, just cut it :\
even when i have vaporize set to true.
i have a custom boolean variable IN the lazor called vaporize.
in my onLaserHit, I have this:
- Code: Select all
(e)=>{vaporize == true && cutter == true ? {e.geom.density = NaN}}
Why is this not working?
It won't ever vaporize an object, just cut it :\
even when i have vaporize set to true.
Please excuse my posts. I am extremely stupid.
-
cdh473 - Posts: 816
- Joined: Tue Sep 01, 2009 12:37 am
- Location: Yes
Re: Lazor cutter/vaporizor w/ custom variables
Your if statement isn't set up correctly, it should be {a} ? {b} : {c}
you have a ? {b}
you have a ? {b}
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Lazor cutter/vaporizor w/ custom variables
err...
umm, i want it to be an AND statement, no else.
so all i really need is
umm, i want it to be an AND statement, no else.
so all i really need is
- Code: Select all
A && B ? {C}
Please excuse my posts. I am extremely stupid.
-
cdh473 - Posts: 816
- Joined: Tue Sep 01, 2009 12:37 am
- Location: Yes
Re: Lazor cutter/vaporizor w/ custom variables
thats what and if staement is, just not with ==
if a and b are true, do c, else do d
so its {a &&b} ? {c} : {d}
its realy exactly the same, but you have to have all the parts, like brakets, otherwise it won't work
if a and b are true, do c, else do d
so its {a &&b} ? {c} : {d}
its realy exactly the same, but you have to have all the parts, like brakets, otherwise it won't work
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Lazor cutter/vaporizor w/ custom variables
well, i tried it the way you said, and it didn't work.
- Code: Select all
(e)=>{{e.laser.cutter == true && e.laser.vaporize == true}(?)({e.geom.density = NaN}) : ({})}
Please excuse my posts. I am extremely stupid.
-
cdh473 - Posts: 816
- Joined: Tue Sep 01, 2009 12:37 am
- Location: Yes
Re: Lazor cutter/vaporizor w/ custom variables
evidently,algodoo cant read boolean variables with onlaserhit, change vaporize to 1 or 0 and you will have to find a way to convert the cutter to a number or substitute something in for it
(e)=>{{e.laser.vaporize == 1 && e.laser.cut == 1} ? {e.geom.density = NaN} : {}}
that works
(e)=>{{e.laser.vaporize == 1 && e.laser.cut == 1} ? {e.geom.density = NaN} : {}}
that works
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Lazor cutter/vaporizor w/ custom variables
ahh, i just changed my method.
here it goes(even though it doesn't work yet):
There is a pulse rifle.
At the end, there is a laser.
By default, it burns through(cuts) every object within a VERY large range, slices it cleanly in half.
Press enter to fire.
Set laser's vaporize variable to 1, it completely vaporizes every object it is fired at.
here it goes(even though it doesn't work yet):
There is a pulse rifle.
At the end, there is a laser.
By default, it burns through(cuts) every object within a VERY large range, slices it cleanly in half.
Press enter to fire.
Set laser's vaporize variable to 1, it completely vaporizes every object it is fired at.
Please excuse my posts. I am extremely stupid.
-
cdh473 - Posts: 816
- Joined: Tue Sep 01, 2009 12:37 am
- Location: Yes
Re: Lazor cutter/vaporizor w/ custom variables
cdh473 wrote:I'm making a pulse rifle, it's got 2 functions- 1 is cut, other is vaporize.
i have a custom boolean variable IN the lazor called vaporize.
in my onLaserHit, I have this:
- Code: Select all
(e)=>{vaporize == true && cutter == true ? {e.geom.density = NaN}}
Why is this not working?
It won't ever vaporize an object, just cut it :\
even when i have vaporize set to true.
As already stated, you need an else statement, regardless of whether you want to have something happen in the event of a false value. To save time with your code, you could just use:
- Code: Select all
vaporize && cutter ? {e.geom.density = NaN} : {}
This just eliminates some un-necessary questions, it makes the code smaller too .
Also, I thought I'd let you work it out yourself (it's not too complicated ), but, you would not be able to modify the object in normal circumstances, because a cutter generates two new objects, you should modify your code to delete the objects, also, why do you want to have cutter AND vaporize? Wouldn't it make sense to have just one or the other?
- gradyfitz
- Posts: 174
- Joined: Tue Sep 01, 2009 8:33 am
- Location: Victoria, Australia
Re: Lazor cutter/vaporizor w/ custom variables
I think you will have some problems getting this to work as a laser thats cutting doesn't register a laser hit and neither does the object beeing cut.
so to get this to work you'll need another laser, but that might get messy as the laser thats turning stuff into water will do that to any object it hits.
so to get this to work you'll need another laser, but that might get messy as the laser thats turning stuff into water will do that to any object it hits.
Phundamentalists, come to the dark side.
We have much cooler toys.
We have much cooler toys.
-
RaRaMalum - [Best newcomer 2010]
- Posts: 280
- Joined: Mon Aug 31, 2009 10:47 pm
9 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests