Switch a laser by collide

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

Switch a laser by collide

Postby Thooto » Tue Mar 29, 2011 8:52 pm

Hello,

I wanted to know if we can, by scripting with on collide, switch a laser. For example; you create a box, and when an other object collide this box, a laser can be switched on.

Thank you for answering, and I hope that despite my bad english you'll understand my question!
Thooto
 
Posts: 45
Joined: Sat Mar 26, 2011 2:02 pm

Re: Switch a laser by collide

Postby Someone Else » Wed Mar 30, 2011 2:41 pm

Hmm... Try changing the color of the box.

If color == [0, 0, 0, 0], the laser will pass right through it.
If color == [1, 1, 1, 1], the laser will be blocked.

Make sure you attach the laser TO the box. And the box's refractiveIndex = 1.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Switch a laser by collide

Postby Kilinich » Wed Mar 30, 2011 2:51 pm

don't listen him ;-)

1) create scene.my. variable (open console with ~ key and type scene.my.laser := 0)
2) set laser maxRays property to {scene.my.laser}
3) set onCollide script of one of the boxes to (e) = {scene.my.laser = 1}
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Switch a laser by collide

Postby Someone Else » Wed Mar 30, 2011 3:31 pm

don't listen him ;)


I try to not use scene.my wherever possible.

Thus, I think that blocking the laser is the way to go. It's phunlet-safe and can be used multiple times within a scene.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Switch a laser by collide

Postby Thooto » Wed Mar 30, 2011 6:03 pm

Ok thank you for your answers! :)

I'll try to use the two ideas you told me!

By the way, thank you two, you gave me many ideas! :P
Thooto
 
Posts: 45
Joined: Sat Mar 26, 2011 2:02 pm

Re: Switch a laser by collide

Postby Kilinich » Wed Mar 30, 2011 10:13 pm

Someone Else wrote:
don't listen him ;)


I try to not use scene.my wherever possible.

Thus, I think that blocking the laser is the way to go. It's phunlet-safe and can be used multiple times within a scene.


oh, sorry, now I've got your point.

btw not only [0, 0, 0, 0] color is transparent, actually any color with zero alpha will fit.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Switch a laser by collide

Postby Someone Else » Thu Mar 31, 2011 2:33 pm

I know. [0, 0, 0, 0] and [1, 1, 1, 1] are easy to remember.

And glad I could help. :thumbup:
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests