SP3 Useful controller scripts
-
I thought it'd be good to have a thread where people can post useful code to go in joint's controller boxes; for people (like me ) who have no experience with ruby script.
0.5-(input)
On a motor joint, this will allow reverse motionMath.sin(frame/10.0)/3.0
Makes a servo oscillateTime.now.sec*(1/60.0)
Similar to above, but moves every secondYou can use multiple inputs as a single controller:
leftx+rightxI tried to make an if function work, but it doesn't let you use spaces.
-
I fixed the spaces bug in the next version. Without spaces it looks like this:
if(frame<30);0.0;else;1.0;end
You can also combine sliders
((0.5-righty)*slider("MaxSpeed"))-slider("Trim")Also sliders can take be configured:
slider("Zero",0) <--Slider has a default position of 0 instead of 0.5
slider("Ten",10,0,10) <--Slider goes from 0-10 and has a default position of 10There is a bug and sliders don't initial show the correct position. Quickly click it to make it update.
-
wow thanks!
-
I need a script for a motor using the triggers (joyRY) and the a button. When the right trigger is pressed (<0.5 for me) the motor should spin, and if a is pressed with the right trigger, it should spin at twice the speed. At 0.5, the motor should be allowed to spin freely (if possible) and a should have no effect. Above 0.5 (left trigger) the motor should stop spinning completely for 2 seconds, then go into reverse at half the normal speed, again with a having no effect.
I hope this isn't too complicated
This is for a car with 'boost' that can brake and reverse using the same button.
-
@cphillips said:
slider("Zero",0) <--Slider has a default position of 0 instead of 0.5
.How do I make the keyboard keys start at default position of Zero
or can't I?
like what I want is to not be able go backwards with a motor but start at zero -
rightx-0.5
For keyboard right/left
-
Any chance a guide or tutorial will be made to explain how to use these codes? It doesn't seem like something you could just pick up and figure out in a few minutes. Oh, and what do you type in the box to duplicate the object connected to the joint, like in the preview video?
Oh, and to make thrusters/magnets controllable:
(0.5-righty)*100000
0.5-: not necessary, but allows reverse directions. 0.8- would make it go 80%forward, 0.5- makes it half and half, so neutral means no thrust, and 0.2- would make it go 20% forwards.
right: right or left, which joystick to use/ wasd or arrow keys.
y: x or y, left and right, or up and down.
*100000: a *, and the strength of the thruster/magnet.
-
Will the beta version have the copy function?
-
I just figured out how to make the copy function work. Its now called Emitters and it will be in next version.
-
do you know what controller scripts are used to make a keyboard key do an action
(like the spacebar, or letters other than WAS and D),
or for a slider to multiply an object like in the pre-release video?Also, do you know why the script
(lefty-0.5)*300+slider('hover')*150
won't work in a thruster controller box? without the '-0.5', it seems to work, but I can't get it to do what I'm trying to.
-
@unknownuser said:
do you know what controller scripts are used to make a keyboard key do an action
(like the spacebar, or letters other than WAS and D),
or for a slider to multiply an object like in the pre-release video?Also, do you know why the script
(lefty-0.5)*300+slider('hover')*150
won't work in a thruster controller box? without the '-0.5', it seems to work, but I can't get it to do what I'm trying to.
that worked fine for me though the controls were switched so I did this
-(lefty-0.5)*300+slider('hover')*150
-
how do you make a motor controled by the arrow keys and have reverse?
-
righty-0.5
righty-0.5
right: controlled by right joystick, or keyboard arrow keys. left would be left joystick, or WASD keys.
y: y= up and down. x=left and right.
-0.5: makes .5 of the speed going backwards, in other words, allows reverse. you could also put 0.5- before righty, if the motor is going in the wrong direction.
Oh, and Phy, thanks; but for me, only half the controls were reversed: I managed to fix it after though.
-
Thanks
-
@unknownuser said:
do you know what controller scripts are used to make a keyboard key do an action
(like the spacebar, or letters other than WAS and D),
or for a slider to multiply an object like in the pre-release video?Also, do you know why the script
(lefty-0.5)*300+slider('hover')*150
won't work in a thruster controller box? without the '-0.5', it seems to work, but I can't get it to do what I'm trying to.
Not yet. But I think I am going to add something like
key("space") or key("1")
Mulitply an object will be the new emitters.
Your script should work as far as I can tell.
Advertisement