Identifying Objets w/ scripting. Is it possible?

About advanced scenes, and the Thyme scripting language used in Algodoo.

Identifying Objets w/ scripting. Is it possible?

Postby roobre » Sat Oct 31, 2009 1:05 pm

Hi!

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
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm

Re: Identifying Objets w/ scripting. Is it possible?

Postby standardtoaster » Sat Oct 31, 2009 6:03 pm

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]}}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Identifying Objets w/ scripting. Is it possible?

Postby Dadasas » Sat Oct 31, 2009 6:06 pm

To do that type
Code: Select all
(e)=>{ e.geom.density < 99999 ? {} : {e.geom.color = [,0,0,1]} }

Because a plane has no density.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Identifying Objets w/ scripting. Is it possible?

Postby roobre » Sat Oct 31, 2009 6:15 pm

Thankd guys!!

I'm going to test it now.

Happy Halloween!!!!
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm

Re: Identifying Objets w/ scripting. Is it possible?

Postby KarateBrot » Sat Oct 31, 2009 7:21 pm

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.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Identifying Objets w/ scripting. Is it possible?

Postby roobre » Sun Nov 01, 2009 1:25 pm

The density does'nt work, i tried it yesterday.

I'll try The other way now...
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm

Re: Identifying Objets w/ scripting. Is it possible?

Postby KarateBrot » Sun Nov 01, 2009 1:35 pm

roobre wrote:The density does'nt work, i tried it yesterday.


like i said :D
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]}}
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Identifying Objets w/ scripting. Is it possible?

Postby roobre » Sun Nov 01, 2009 4:38 pm

Yeah, but i need that the script work w/ everything excepting planes, so it must to be "plane" ;)
User avatar
roobre
 
Posts: 11
Joined: Sat Sep 05, 2009 5:14 pm

Re: Identifying Objets w/ scripting. Is it possible?

Postby Dadasas » Sun Nov 01, 2009 6:17 pm

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 :oops: , It is supposed to be the other way around.
User avatar
Dadasas
 
Posts: 46
Joined: Tue Sep 01, 2009 2:03 am

Re: Identifying Objets w/ scripting. Is it possible?

Postby KarateBrot » Sun Nov 01, 2009 11:31 pm

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? :wtf:
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests

cron