Oncollide Scripting
18 posts • Page 1 of 1
Oncollide Scripting
Well since I dont know if they are gonna move the forums im gonna start RE-posting Important topics.
[From: Physics.Dude]
I put together a little guide of oncollide scripting since I always see people asking how to do this. So here it is
and if you need to change values just mess with the numbers, letters, or true and false.
Water Spawner
(e)=>{Scene.addWater({vecs = [e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos]})}
Circle Spawner
(e)=>{scene.addCircle({ radius := 0.1; density := 2.0; restitution := 0.5; friction := 0.5; pos := e.pos }) };
Box Spawner
(e)=>{ Scene.addBox({size := [0.83575642, 0.27858579]; density := 2.00; pos := e.pos; restitution := 0.5; friction = 0.5; angle := 0}) }
----------------------------------------------------------------------------------------------------------------------------------
Self Collision
(e)=>{heteroCollide = false;}
Collide water
(e)=>{collideWater = true }
----------------------------------------------------------------------------------------------------------------------------------
Shape color([R,G,B,A] 0-255)
(e)=>{color = [1.0, 0.0, 0.0, 1.0]}
Text Color ([R,G,B,A] 0-255)
(e)=>{textColor = [1.0, 0.0, 0.0, 1.0]}
Text Size
(e)=>{textScale = 3;}
----------------------------------------------------------------------------------------------------------------------------------
Density
(e)=>{density = 10.02;}
Repel
(e)=>{attraction = - 20;}
Attract
(e)=>{attraction = 50;}
Killer
(e)=>{killer = true }
----------------------------------------------------------------------------------------------------------------------------------
"Anti-Gravity"
(e)=>{Sim.gravityAngleOffset = 3.1415927;}
Pause Sim
(e)=>{sim.running = false;}
Change Zoom
(e)=>{scene.camera.zoom = 17.700001}
change Camra Pan
(e)=>{scene.camera.pan = [ - 446, 14.6];}
----------------------------------------------------------------------------------------------------------------------------------
Set destroy key (With spawned objects)
buttonDestroy := "e"
Set collision (With spawned objects)
collideSet := 0;
Add Text (With spawned objects)
text := "Hello World!"
----------------------------------------------------------------------------------------------------------------------------------
If you wish to use more than one script in an object then the format should be as follows
Say you want to combine (e)=>{attraction = 50;} and (e)=>{color = [1.0, 0.0, 0.0, 1.0]}
You would write it as… note the semicolon and spaces.
(e)=>{ attraction = 50; color = [1.0, 0.0, 0.0, 1.0]}
[From: Physics.Dude]
I put together a little guide of oncollide scripting since I always see people asking how to do this. So here it is
and if you need to change values just mess with the numbers, letters, or true and false.
Water Spawner
(e)=>{Scene.addWater({vecs = [e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos, e.pos]})}
Circle Spawner
(e)=>{scene.addCircle({ radius := 0.1; density := 2.0; restitution := 0.5; friction := 0.5; pos := e.pos }) };
Box Spawner
(e)=>{ Scene.addBox({size := [0.83575642, 0.27858579]; density := 2.00; pos := e.pos; restitution := 0.5; friction = 0.5; angle := 0}) }
----------------------------------------------------------------------------------------------------------------------------------
Self Collision
(e)=>{heteroCollide = false;}
Collide water
(e)=>{collideWater = true }
----------------------------------------------------------------------------------------------------------------------------------
Shape color([R,G,B,A] 0-255)
(e)=>{color = [1.0, 0.0, 0.0, 1.0]}
Text Color ([R,G,B,A] 0-255)
(e)=>{textColor = [1.0, 0.0, 0.0, 1.0]}
Text Size
(e)=>{textScale = 3;}
----------------------------------------------------------------------------------------------------------------------------------
Density
(e)=>{density = 10.02;}
Repel
(e)=>{attraction = - 20;}
Attract
(e)=>{attraction = 50;}
Killer
(e)=>{killer = true }
----------------------------------------------------------------------------------------------------------------------------------
"Anti-Gravity"
(e)=>{Sim.gravityAngleOffset = 3.1415927;}
Pause Sim
(e)=>{sim.running = false;}
Change Zoom
(e)=>{scene.camera.zoom = 17.700001}
change Camra Pan
(e)=>{scene.camera.pan = [ - 446, 14.6];}
----------------------------------------------------------------------------------------------------------------------------------
Set destroy key (With spawned objects)
buttonDestroy := "e"
Set collision (With spawned objects)
collideSet := 0;
Add Text (With spawned objects)
text := "Hello World!"
----------------------------------------------------------------------------------------------------------------------------------
If you wish to use more than one script in an object then the format should be as follows
Say you want to combine (e)=>{attraction = 50;} and (e)=>{color = [1.0, 0.0, 0.0, 1.0]}
You would write it as… note the semicolon and spaces.
(e)=>{ attraction = 50; color = [1.0, 0.0, 0.0, 1.0]}
Chronos wrote:There's nothing wrong with swearing. They're just words. People just think they have a bad meaning. What's the difference between shit and poo? Nothing. They're the same.
-

Rhett97 - Posts: 522
- Joined: Mon Aug 31, 2009 10:32 pm
Re: Oncollide Scripting
Yes Niffirg i think made a Fixate spawner but since its on collision spawning it would spawn in the TINY space between the two objects to it would instantly delete
Chronos wrote:There's nothing wrong with swearing. They're just words. People just think they have a bad meaning. What's the difference between shit and poo? Nothing. They're the same.
-

Rhett97 - Posts: 522
- Joined: Mon Aug 31, 2009 10:32 pm
Re: Oncollide Scripting
shouldnt this be in the thyme section? 
TheWinkits wrote:They both looks of cuking amazing
-

Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: Oncollide Scripting
no because it was made in 5.28 and algodoo might have changed some code
Chronos wrote:There's nothing wrong with swearing. They're just words. People just think they have a bad meaning. What's the difference between shit and poo? Nothing. They're the same.
-

Rhett97 - Posts: 522
- Joined: Mon Aug 31, 2009 10:32 pm
Re: Oncollide Scripting
I think it should go here, algodoo is like an alien to phun and if there's anything we know about aliens it's that they are short green guys with ray guns.
-

Mystery - Posts: 2802
- Joined: Thu Sep 03, 2009 1:16 pm
- Location: Southern Australia
Re: Oncollide Scripting
dont forget the probes 
this will help a lot of people!
this will help a lot of people!
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Oncollide Scripting
This just made my life a whole lot easier!!! I used to have to make logical guesses and try again and again!
I'm not CrystalCube anymore.
-

CrystalCube - Posts: 35
- Joined: Sat Sep 26, 2009 11:48 pm
- Location: Poulsbo WA
Re: Oncollide Scripting
Is there a code that can be used to cahnge the simulation time?
-

EPR_89 - Posts: 19
- Joined: Thu Sep 10, 2009 1:14 pm
- Location: Germany
Re: Oncollide Scripting
Changing the value of sim.time? No. Sim.time is a constant value and you cannot change it.
-

standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Oncollide Scripting
how do you script springs to make them change length
i cant make the variable thing stay in the length box of the spring script menu
i cant make the variable thing stay in the length box of the spring script menu
BTC: 12wcLxBejr6rhCk6WPyVSNmkjwwbxXEvBG
LTC: LQ17UdL71xzLCprSfkoWUQXDXWuHjx2nf9
FTC: 6nfbPuFbtk8uNokYSsVfbzc5393ggxNGDC
polygons > textures
STUFFES:
http://www.algodoo.com/algobox/profile.php?id=4540
LTC: LQ17UdL71xzLCprSfkoWUQXDXWuHjx2nf9
FTC: 6nfbPuFbtk8uNokYSsVfbzc5393ggxNGDC
polygons > textures
STUFFES:
http://www.algodoo.com/algobox/profile.php?id=4540
-

sheepborg - Posts: 203
- Joined: Sat Dec 05, 2009 10:44 pm
- Location: North Carolina USA
Re: Oncollide Scripting
sheepborg wrote:how do you script springs to make them change length
You can't
sheepborg wrote:i cant make the variable thing stay in the length box of the spring script menu
Press enter when you're done typing. If you mean that it disappears after a while, it happens to everyone.
TheWinkits wrote:They both looks of cuking amazing
-

Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: Oncollide Scripting
Chronos wrote:sheepborg wrote:how do you script springs to make them change length
You can't
Yes you can.
Make a variable.
- Code: Select all
scene.my.length = 1
In the length part of the script menu of the spring(remember to press enter when you are done) put:
- Code: Select all
{scene.my.length}
Now, whenever you change the variable scene.my.length, the length of the spring will change.
-

standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Oncollide Scripting
Oh, he said springs. >.< I thought he said "script things."
TheWinkits wrote:They both looks of cuking amazing
-

Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: Oncollide Scripting
Chronos wrote:sheepborg wrote:how do you script springs to make them change length
You can'tsheepborg wrote:i cant make the variable thing stay in the length box of the spring script menu
Press enter when you're done typing. If you mean that it disappears after a while, it happens to everyone.
what non-sense!!!
about that script springs to make them change length thing it's possible!
1. make a spring.
2. press F11
3. A thing with words would pop up at the top of the program
4. type in a variable
5. give the variable a value (number)
6. press F11 to close it
7. make sure you're on advanced mode
8. click the spring and go into script menu
9. in "springLength = (number)" or something similar, change the number to scene.my.(whatever variable you named it) and put it in a {} bracket and press enter.
10. whatever value you give the variable like 30, your spring length will be 30m.
more about scripting...
a variable is like a memory chip, if you prss F11 that thing that pops up is called the variable console and you can type in all the variables you want. so if you type scene.my.g = 10 in the variable console the variable scene.my.g will hold a value of 10.. to be continued...
- matt28
- Posts: 7
- Joined: Wed Dec 23, 2009 11:19 pm
Re: Oncollide Scripting
matt28 wrote:Chronos wrote:sheepborg wrote:how do you script springs to make them change length
You can'tsheepborg wrote:i cant make the variable thing stay in the length box of the spring script menu
Press enter when you're done typing. If you mean that it disappears after a while, it happens to everyone.
what non-sense!!!
about that script springs to make them change length thing it's possible!
1. make a spring.
2. press F11
3. A thing with words would pop up at the top of the program
4. type in a variable
5. give the variable a value (number)
6. press F11 to close it
7. make sure you're on advanced mode
8. click the spring and go into script menu
9. in "springLength = (number)" or something similar, change the number to scene.my.(whatever variable you named it) and put it in a {} bracket and press enter.
10. whatever value you give the variable like 30, your spring length will be 30m.
more about scripting...
a variable is like a memory chip, if you prss F11 that thing that pops up is called the variable console and you can type in all the variables you want. so if you type scene.my.g = 10 in the variable console the variable scene.my.g will hold a value of 10.. to be continued...
Chronos wrote:Oh, he said springs. >.< I thought he said "script things."
Learn to read. I already know about scripting, so don't try to teach or lecture me about it. Just stop being a forum noob and actually learn about me before making assumptions.
TheWinkits wrote:They both looks of cuking amazing
-

Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: Oncollide Scripting
by the time i got back to this page i have already gotten the scripting stuff down
the problem was that i forgot to set the custom variable before trying to type it int the spring's length box
thanks for the help even if i didnt use it!
the problem was that i forgot to set the custom variable before trying to type it int the spring's length box
thanks for the help even if i didnt use it!
BTC: 12wcLxBejr6rhCk6WPyVSNmkjwwbxXEvBG
LTC: LQ17UdL71xzLCprSfkoWUQXDXWuHjx2nf9
FTC: 6nfbPuFbtk8uNokYSsVfbzc5393ggxNGDC
polygons > textures
STUFFES:
http://www.algodoo.com/algobox/profile.php?id=4540
LTC: LQ17UdL71xzLCprSfkoWUQXDXWuHjx2nf9
FTC: 6nfbPuFbtk8uNokYSsVfbzc5393ggxNGDC
polygons > textures
STUFFES:
http://www.algodoo.com/algobox/profile.php?id=4540
-

sheepborg - Posts: 203
- Joined: Sat Dec 05, 2009 10:44 pm
- Location: North Carolina USA
18 posts • Page 1 of 1
Return to Phun Edition in general
Who is online
Users browsing this forum: No registered users and 1 guest




