how can i bind a key to a certain collision

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

how can i bind a key to a certain collision

Postby kronicphun » Tue Aug 30, 2011 4:53 pm

is it posibal to have a certain key activate when say ... geom. A collides with geom. B
kronicphun
 
Posts: 1
Joined: Tue Aug 30, 2011 4:47 pm

Re: how can i bind a key to a certain collision

Postby bozbez » Wed Aug 31, 2011 11:54 am

No, but you could cause an event by executing a function in the oncollide...
Image

Go here. Now. That's Now. Not in 5 minutes. Now.
User avatar
bozbez
 
Posts: 149
Joined: Tue Apr 12, 2011 7:01 pm

Re: how can i bind a key to a certain collision

Postby Ivan » Wed Aug 31, 2011 12:02 pm

The simpliest way to do this might be using a laser.


You can make a key controlled laser and set the onLaserHit variable in the script menu to: (e)=>{e.geom.collideset=whateverCollidesetYouWant}.
This would make a laser change the collideset of the objects it hits.

Instead of whateverCollidesetYouWant type:
1 for A
2 fro B
4 for C
8 for D
16 for E
...
For instance, if you want a B collideset, make onLaserHit = (e)=>{e.geom.collideset=2}
If you want it to be A and B, type 3 (1+2). B and D would be 10 (2+8). A, C and E would be 21 (1+4+16).

Another better method is to do the following:
1. Open the console (press tilde, F10 or F11 - depending of the version of Algodoo you use)
2. Declare a scene.my variable - for instance, type scene.my.collideset := 1 and press enter
3. Make a few key controlled lasers and a box for the lasers to hit it.
4. Set the onLaserHit of the lasers to (e)=>{scene.my.collideset=whateverCollidesetYouWant}.
5. Set the collideset in the script menu of your object to collideSet = {scene.my.collideset}.

See the attached scene.
Attachments
CollideSet.phz
(13.75 KiB) Downloaded 40 times
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: how can i bind a key to a certain collision

Postby Someone Else » Fri Sep 02, 2011 4:21 am

If you want to turn on a motor or laser onCollide, you can use maxRays = 0 to turn a laser off and maxRays = 1000 to turn it back on, or for motors you can turn it off via motorSpeed = 0 for autobrake or motorTorque = 0 for non-autobrake, and set either of those to any other value to turn it back on...

Do exactly what the second part of Ivan's post says, only with scene.my.maxRays or motorSpeed or motorTorque... ... ...

Credit to Kilinich on the maxRays thing.
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 3 guests