Timer variable to SPIV?
-
Pt this code somewhere...
if key("space")==1 then setVar("time",10);end;
That will set time to 10 on key space...
setVar("time",getVar("time")-1)
Put that in onTick with a rate of 30 frame. That will reduce time by 1 every second.
-
Else, if you want something to start at a frame then
if frame==350 then setVar("time",10);end;
Which means, after 350 frames, the timer will be set to 10.
-
Thanks!
But that is not the thing I searching for...
cause:@unknownuser said:
if key("space")==1 then setVar("time",10);end;
only set a standard variable to 10 with the name "time".
I search for something that count to ten (or something else), and when it reach the number it would set the variable to 1 (one).
and with another script it would reset the timer/counter.
your script is good, nothing wrong, but not the thing i searched for.
but thanks for the help, I appreciate that
-
if frame==0 then setVar("time",300); setVar("var",0); end; #Sets 'time' to 300 frames, and 'var' to 0 on the first frame of the simulation if key("space")==1 then setVar("time",300); end; #Resets 'time' to 300 when space is pressed setVar("time",getVar("time")-1); #reduces 'time' by 1 every frame if getVar("time")<=0 then setVar("var",1); end; #Sets 'var' to 1 when 'time' reaches 0
That's a self-contained script to go in onTick. Time is measured in frames (it's easier), and the timer will start on frame 0. Pressing space will reset the timer. Once the timer reaches 0, a variable called 'var' is set to 1; resetting the timer will NOT change this variable back. If this still isn't right, please detail exactly what you want it to do.
With regards to your original question, you'll have to ask Chris; but, as we've shown, what you ask is possible already, just slightly longer than your suggested way.
-
SPIV will have a timer but not exactly how you suggest:
#start a timer that will "go off" in 10 frames. startTimer(10){ #when 10 frame have passed do this code setVar("timer1",1); }
Here are the events that I am planning on for SPIV.
#tick,timer
#start,end,create,destroy
#key,keyDown,keyUP
#button,joy
#click,drag,unclick
#onSetVarThe way it will work is there will be an addEvent button in the UI. Then you
select which event from a list and the the code section will appear
in the UI.In the code field you will be able to do almost anything. Every property and setting on an object will be setable (like magnetic, static, nocollison, etc).
You can force objects to move or rotate, copy them, create and break joints.It will be pretty cool what you can do. Here is an example. Make a box and name it "carbody" then create a disk for a wheel. In the UI add a "start" event. Start is called when the simulation first starts and then never again. In the code section you could put:
connectTo(findBody("carbody"),"hinge")
Now when you start the simulation the wheel body will be connect to the carbody with a hinge (down the center of the wheel). Now you can make copies of the wheel and they too will connect to "carbody".
-
I take it back. You can do what you want in SP3. Its a bit dangerous though. Put this in onTick:
if(frame==10) UI.start_timer(10){setVar("timer1",1)} end
Now here are some important things you need to be aware of:
First the 10 is seconds not frames.You dont want to create very many timers. A few at most. And you dont want to create a timer every frame! In the above example I start the timer at frame 10.
After 10 seconds the value of "timer1" will be set to 1.Finally, this timer operates outside the simulation so it will happen even if the simulation is paused. It will even happen after the simulation has finished. AND if you use large delays then it could happen during the next run of the simulation:
Start a timer set to go off in 30 seconds. Run the simulation for 5 sec and then restart. 25 seconds later the first timer will go off and set the value of timer1. Then 5 seconds later you will get the second one.
Use short delays.
-
Will the connection depend on the axis of the object?
-
@unknownuser said:
Will the connection depend on the axis of the object?
It will default to the axis of the object and you can change the axis. Or you can specify a object to be the axis. Group a disk with a cylinder named "hingepin" where you want the axis to be. Then:
connectTo("carbody","hinge","hingepin")
-
THANKS CPhillips!!
this code was the thing I searched for
if(frame==10) UI.start_timer(10){setVar("timer1",1)} end
But I start/reset it with a "getVar" command... and it works perfect!
if getVar('start')==1 UI.start_timer(5){setVar("timer1",1)} end if getVar('stop')==1 setVar('timer1',0) end
Why should I don't use it to many timers at the same project? Would Sketchup crash??
Thanks again!
I'm look forward to see SPIV, can it be better than it is now?:D -
I don't think it would crash. It would probably get slow if you have too many tho.
Advertisement