Is there a script to put in an axle to make this occur?

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

Is there a script to put in an axle to make this occur?

Postby sandhaul » Thu Dec 15, 2016 8:23 am

hi everyone, sorry if you've seen me everywhere, i just wanted to ask, is there a script that you can put in an axle to make it rotate to a particular angle, and by hotkey; also when you press that hotkey again it goes back to the original spot? i only ask this so I can make a transformer for myself, and my friend, and also make something simply rotate to a particular angle, like 90 degree or 140 degree, thank you everyone!
sandhaul
 
Posts: 14
Joined: Mon Dec 05, 2016 12:48 am

Re: Is there a script to put in an axle to make this occur?

Postby pnvv » Thu Dec 15, 2016 3:30 pm

Not hard. Just use BendTarget.
Image

(/)(°,,,°)(/)
User avatar
pnvv
 
Posts: 670
Joined: Tue Aug 26, 2014 11:46 pm
Location: Disunited States of America

Re: Is there a script to put in an axle to make this occur?

Postby sandhaul » Fri Dec 16, 2016 5:23 am

can you give me the script to put into it?
sandhaul
 
Posts: 14
Joined: Mon Dec 05, 2016 12:48 am

Re: Is there a script to put in an axle to make this occur?

Postby Kilinich » Fri Dec 16, 2016 8:55 am

In hinge's script menu:

Code: Select all
bend = true;
bendTarget = 1;
bendConstant = 50000;
motorTorque = 50000;
onKey = (e) => {e.pressed ? {
  e.keyCode == "a" ? {
    bendTarget == 1 ? {bendTarget =2}:{bendTarget = 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: Is there a script to put in an axle to make this occur?

Postby sandhaul » Sat Dec 17, 2016 5:05 am

Thanks, kilinich!
sandhaul
 
Posts: 14
Joined: Mon Dec 05, 2016 12:48 am

Re: Is there a script to put in an axle to make this occur?

Postby sandhaul » Sat Dec 17, 2016 5:06 am

how do i set what angle it can bend to? thank you.
sandhaul
 
Posts: 14
Joined: Mon Dec 05, 2016 12:48 am

Re: Is there a script to put in an axle to make this occur?

Postby Kilinich » Sat Dec 17, 2016 1:47 pm

bendTarget is angle in radians.
You could add some constant variables to store angles:

Code: Select all
_angle1 = math.pi /4;
_angle2 = math.pi /2;
bend = true;
bendTarget = _angle1;
bendConstant = 50000;
motorTorque = 50000;
onKey = (e) => {e.pressed ? {
  e.keyCode == "a" ? {
    bendTarget == _angle1 ? {bendTarget = _angle2}:{bendTarget = _angle1}
  }:{}
}:{}}
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: Is there a script to put in an axle to make this occur?

Postby sandhaul » Sat Dec 17, 2016 11:25 pm

thanks kilinich.
sandhaul
 
Posts: 14
Joined: Mon Dec 05, 2016 12:48 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests

cron