Using formulas
-
oh no. that will select it all if you click on it. That will help copy the formula so you can paste it in the fields
-
ok thanks again for the help. Do you know where I can find the "codes" we can enter?
-
Scripting is kind of up to you; what you want is to end up with a value, which is what the joint/thruster/emitter/magnet/whatever will be set to. Scripts run each frame of the simulation, so if something changes, like an input from a joystick, then the script will update using this new input. The codes do logical calculations, putting them together, changing them and making them do what you want is up to you; a basic understanding of algebra will help. Search through the forums for the specifics, but there are 'if' functions, which do a test and give a value for either true or false. 'if, elsif' functions do a new test if the first one was false. There is a script that will cycle through values based on the frame number, and there are little snippets which do nice, easy to understand stuff like '0.5-lefty', which, on a motor, allows reversable control using lefty, which is w,s or the left joystick's up/down.
-
Thank you Wacov. I'm a Delphi programmer so I'll have no problem with little functions. What I meant to ask was, where do I find the "keywords" that the blue fields understand. There is the "if,else" but is there any "not,and,or,xor", there is "lefty, leftx" but what about other ones? What about math like sin, cos etc? and of course, things like +-* (/ or \ or both?) what about =, ==, === which is used? bla bla bla. you know! Or maybe I'm looking too hard, is it a ruby script we enter? and all ruby functions will work? Sorry for my ignorance.
-
Its all Ruby syntax. So anything that is legal Ruby should work.
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.htmlSin is Math.sin()
The SP specific keywords are not fully documented yet. My top priority.
-
Some useful stuff (in the new syntax):
joy("leftx")
joy("lefty")
joy("rightx")
joy("righty")
joyRY (Analogue triggers on a 360 style pad)joybutton("a,b,x,y,rb,lb")
key("q,w,e,r,t,y,etc")All the buttons work through joystick emulation, with off being 0.0 and on 1.0. leftx and y are also w,a,s,d on the keyboard, rightx and y are the arrow buttons.
-
Perfect Thank you guys
-
Oh, don't forget setVar("var") and getVar("var"). This creates and retrieves global variables that carry between frames.
-
@wacov said:
Oh, don't forget setVar("var") and getVar("var"). This creates and retrieves global variables that carry between frames.
This will be very handy, thank you.
-
One other variable function is
#get the var foo and set it to 0 v=getSetVar("foo",0)
It can be a useful shortcut.
Advertisement