Deleting with lasers

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

Deleting with lasers

Postby tallman1996 » Fri May 18, 2012 11:36 pm

There is a certain object I want to be able to delete when it is hit by a laser. What scripting code would I use to do so?
I don't want anything else to be destroyed by the laser though, just one object.
User avatar
tallman1996
 
Posts: 13
Joined: Mon Mar 22, 2010 10:16 pm

Re: Deleting with lasers

Postby tatt61880 » Sat May 19, 2012 2:41 am

Not so difficult.

Laser:
onLaserHit = (e)=>{e.geom.materialName == "DeletableGeom" ? {Scene.RemoveEntity(e.geom)} : {}}

Geom:
materialName = "DeletableGeom";

== Explanation ==
You can use Ternary operation for conditional-branch.
With Thyme, ternary operation needs {}. i.e. condition ? {true case} : {false case} . (cf. 1.8.0 Thyme expression error)
e.geom is a geom which is hit by laser.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Deleting with lasers

Postby egkteam » Sat Jun 09, 2012 1:03 pm

Just like this:

onLaserHit:
Code: Select all
(e)=>{e.other.density = 0}


onCollide/onHitByLaser:
Code: Select all
(e)=>{density = 0}


So basically just make the density to 0 and the object will vanish.
My Algobox account (inactive)
P.S. My real name is Emmanuel so call me that way.
egkteam
 
Posts: 91
Joined: Mon May 21, 2012 3:49 pm
Location: East Java, Indonesia

Re: Deleting with lasers

Postby monstertje3 » Sat Jun 09, 2012 3:37 pm

egk, in the newer algodoo version they made it so you can use
Scene.RemoveEntity(e.geom)
as a entity remover, this is more reliable then setting the density 0
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Deleting with lasers

Postby tatt61880 » Sat Jun 09, 2012 5:01 pm

monstertje3 wrote:as a entity remover, this is more reliable then setting the density 0

Oh, is this true? ...jk :D
I also believe that Scene.RemoveEntity is more proper for deleting entity than density = 0 method. ;)
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Deleting with lasers

Postby egkteam » Sun Jun 10, 2012 5:35 pm

How do you use that using scene.my?
My Algobox account (inactive)
P.S. My real name is Emmanuel so call me that way.
egkteam
 
Posts: 91
Joined: Mon May 21, 2012 3:49 pm
Location: East Java, Indonesia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests