Identifying Objets w/ scripting. Is it possible?
10 posts • Page 1 of 1
Identifying Objets w/ scripting. Is it possible?
Hi!
I wonder if it's possible to identify objets in Algodoo using lasers.
P.e:
This code will change the colour of everything excepting planes.
Obviously, that code doesn't exists, but, Is it possible?
Regards
I wonder if it's possible to identify objets in Algodoo using lasers.
P.e:
- Code: Select all
onLaserHit = (e)=> {e.geom.is-a-plane}? {} : {e.geom.color := [0.0, 0.0, 0.0, 1.0]}
This code will change the colour of everything excepting planes.
Obviously, that code doesn't exists, but, Is it possible?
Regards
-
roobre - Posts: 11
- Joined: Sat Sep 05, 2009 5:14 pm
Re: Identifying Objets w/ scripting. Is it possible?
It is possible. use e.geom + "" to identify the type of object. Compare them by using strings.
- Code: Select all
onLaserHit = (e)=>{e.geom + "" == "plane" ? {} : {e.geom.color = [0, 0, 0, 1]}}
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Identifying Objets w/ scripting. Is it possible?
To do that type
Because a plane has no density.
- Code: Select all
(e)=>{ e.geom.density < 99999 ? {} : {e.geom.color = [,0,0,1]} }
Because a plane has no density.
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Identifying Objets w/ scripting. Is it possible?
Thankd guys!!
I'm going to test it now.
Happy Halloween!!!!
I'm going to test it now.
Happy Halloween!!!!
-
roobre - Posts: 11
- Joined: Sat Sep 05, 2009 5:14 pm
Re: Identifying Objets w/ scripting. Is it possible?
Dadasas wrote:To do that type
- Code: Select all
(e)=>{ e.geom.density < 99999 ? {} : {e.geom.color = [,0,0,1]} }
Because a plane has no density.
normally it hasn't but otherwise nothing in algodoo would have a density. because of that the density is defined as "mass per m²" instead of "mass per m³".
You just posted a code that changes the color of every object that has a density above 99999 kg/m² and basically no object has such a HIGH!!! density. in other words: nothing will happen.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Identifying Objets w/ scripting. Is it possible?
The density does'nt work, i tried it yesterday.
I'll try The other way now...
I'll try The other way now...
-
roobre - Posts: 11
- Joined: Sat Sep 05, 2009 5:14 pm
Re: Identifying Objets w/ scripting. Is it possible?
roobre wrote:The density does'nt work, i tried it yesterday.
like i said
standardtoaster's code will work. but instead of "plane" there has to be "box".
- Code: Select all
onLaserHit = (e)=>{e.geom + "" == "box" ? {} : {e.geom.color = [0, 0, 0, 1]}}
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Identifying Objets w/ scripting. Is it possible?
Yeah, but i need that the script work w/ everything excepting planes, so it must to be "plane"
-
roobre - Posts: 11
- Joined: Sat Sep 05, 2009 5:14 pm
Re: Identifying Objets w/ scripting. Is it possible?
KarateBrot wrote:Dadasas wrote:To do that type
- Code: Select all
(e)=>{ e.geom.density < 99999 ? {} : {e.geom.color = [,0,0,1]} }
Because a plane has no density.
normally it hasn't but otherwise nothing in algodoo would have a density. because of that the density is defined as "mass per m²" instead of "mass per m³".
You just posted a code that changes the color of every object that has a density above 99999 kg/m² and basically no object has such a HIGH!!! density. in other words: nothing will happen.
Oh sorry I posted the wrong code , It is supposed to be the other way around.
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Identifying Objets w/ scripting. Is it possible?
roobre wrote:Yeah, but i need that the script work w/ everything excepting planes, so it must to be "plane"
but then... what's a "plane" in algodoo?
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
10 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 12 guests