It's just the ruby script way. I guess the @/@@/$ bit saves it, so it works between frames, unlike normal ruby variables
Posts
-
RE: Variables
-
RE: Some Problems with Servos
Jackson, get SP3. I don't know why everyone is downloading SP2, but 3 has been out for a while now has has a bunch of useful features... like the noCollision state. Objects will move normally, but they can't collide with anything. Links are at:
http://sketchyphysics.wikia.com/wiki/SketchyPhysicsWiki -
Variables
Found out a bit more about ruby variables; turns out you can set variables properly without setVar or getVar:
@varThat's it! To set, use:
@var=1You can't use it properly with onTouch, but once onUnTouch comes that won't be a problem either. The thing is, it's not working how it's supposed to; it's acting like a global variable. It should be specific to a certain object... technically, $var is a global variable, but it appears to work the same.
-
Sound API...?
Chris, I saw a post from you mentioning a sound API... what exactly would this let us do, aside from uploading sounds along with models? Will sounds stop playing at the end of the simulation? Will we be able to overlap sounds on windows? I'd really like to have a way to play looping engine sounds that are modified dynamically, speeding up/slowing down as a variable changes.
-
RE: New Toggle Script (Help Needed)
I'll be happier than anyone if there's a simpler way, but the problem is detecting key presses as individual events. I believe that onButton/Key events will be added in the next version, or at least before SPIV; that'll make things a whole lot easier... but I'm more excited about the ability to detect what onTouch is hitting. For the next motorsketch, I'll (hopefully) be able to add AI opponents that follow routes through the track, attacking each other and the player, along with a lap counter!
-
RE: New Toggle Script (Help Needed)
http://www.sketchucation.com/forums/scf/viewtopic.php?f=61&t=17981 ... I wish Chris would stickify it... or make a sticky post with all the good scripts in...
-
RE: New Toggle Script (Help Needed)
Are you really this inclined to avoid using my script? -
RE: New Toggle Script (Help Needed)
@unknownuser said:
@wacov said:
I see what you're trying to do, but honestly, it won't work. Mine is long for a reason

There's a 50/50 chance of actually toggling. I mean that literally. Oh, and hold down space, see what happens... I'll let you figure out what's going on.
!!201ST POST! YAY!!
I sort of want it to that, i want to give an effect of 'old' machinary, which does not always work.
... really? And the whole spastic vibration thing is alright with you?

-
RE: Some Problems with Servos
Uh, BTM... click the picture. Anyway, it may have something to do with the fact you've tripled up the servos. Joints aren't meant to be used that way, so in this case, the movement of each servo is partially prevented by the other two.
-
RE: New Toggle Script (Help Needed)
I see what you're trying to do, but honestly, it won't work. Mine is long for a reason

There's a 50/50 chance of actually toggling. I mean that literally. Oh, and hold down space, see what happens... I'll let you figure out what's going on.
!!201ST POST! YAY!!
-
RE: Acceleration script (working)
Nah, how fast it accelerates. Normal cars don't go from 0-120 in half a second; the script fixes that -
RE: Sketchy problem :)
Here; I set the actual hook to 'ignore' and added some hidden box shapes to get the physics shape right.
-
Acceleration script (working)
I decided to make this when I realised my new vehicle didn't feel heavy enough; I wanted it to be fast, but I didn't want instant acceleration and decceleration. This script deals with both problems, and you can adjust the acceleration and braking to your needs by changing the local variables at the top... well, here it is:
#Acceleration Script by Wacov accel=0.005 deccel=0.015 if frame==0; then; setVar("speed",0.5); end; if getVar("speed")>joyRY and getVar("speed")>0.5; setVar("speed",getVar("speed")-deccel); elsif getVar("speed")<joyRY and getVar("speed")<0.5; setVar("speed",getVar("speed")+deccel); end; if joyRY>0.5; then; setVar("speed",getVar("speed")+accel); end; if joyRY<0.5; then; setVar("speed",getVar("speed")-accel); end; if joyRY==0.5 and getVar("speed")<0.5; setVar("speed",getVar("speed")+deccel); elsif joyRY==0.5 and getVar("speed")>0.5; setVar("speed",getVar("speed")-deccel); end;It will not accelerate beyond the input, so the overall speed is controllable. To change the control, change all the 'joyRY's to whatever you want.
To use, place in any onTick field. For a vehicle's motors, use:
0.5-getVar("speed")In the motor's controler field. Hope this is useful!
Have at look at: http://sketchup.google.com/3dwarehouse/details?mid=9047719249a2da26cd8ad826e9017b8&prevstart=0 To see it at work.
-
RE: Coding Field
Actually there can be as many ends as you want. But in this case, there could be a conflict, so you may as well use elsif. Also, onTick works fine and doesn't need an event to trigger it; it's a 'frame' event, occuring every frame or every rate frame. Next version there should be global script, which'd be perfect for this.
-
RE: Frame-cycle
Huh; my one won't work, because, as I just found out, it doesn't seem to be possible to set varables using it. You could always use mine in the controller fild of each individual joint...
The [1,2,3,4] part holds the list of output numbers. So, in the controller field, the joint would move to 1, then 2, then 3, then 4, then back to 1, etc etc. Phonic's way is very different.
-
RE: Frame-cycle
Hmm... this;
if getVar("XXX")==1; [1,2,3,4,5,setVar("XXX",0)][(frame/50)%6]; else; 0; endDoesn't work, I can't see why though. This:
if getVar("XXX")==1; [1,2,3,4,5,6][(frame/50)%6]; else; 0; endDoes work, but can't reset the variable at the end, to stop repetition; but it will only start, and continue to work, when 'XXX' is 1.. Chris knows about this stuff; as far as I can tell, in the first one 'XXX' is being reset every frame, instead of just at the end. Why is this??
EDIT:
BTW, the:[1,2,3,4,5][(frame/50)%5]Is much easier to use that the long, complex if function way. First [] holds the list of values, the number after 'frame' is the number of frames you want between each new value.
-
RE: Maximum Sound Duration
Remember that the sounds continue playing after the simulation has stopped!