loading
 
Image Count
Ay from United Kingdom  [3 posts]
17 year
Hi,

I'd like to use the variable, Image Count, to measure time.
Is the Image Count counting per 1/30 second??
Or, is there any more-reasonable methods to do that?

Thank you in advance,
Best regards,

Ay
Anonymous 17 year
Hi Ay,

  Sure the two ways I can think of is use vbscript see http://www.roborealm.com/forum/index.php?thread_id=747 or use the timer module (Other -> Timer) and use milliseconds
Ay from United Kingdom  [3 posts] 17 year
Thank you for your suggestion.

I have still a few questions about the use of the vbscript and the timer.
Especially, the vbscript is already in the loop, but if I use the timer, does the vbscript stop when the timer reaches at the time I set up?

What I want to do is repeat the loop just forever.
In the vbscript, there can be some if statements.
When the certain time (millisecond or second) comes, the if statement finishes, and then I want to perform another if statement.
When the all of performances in the loop are finished, again I want to start the loop and repeat them.

So, I used the image count..
However, I found the image count shows the increment is not really constant.

Best regards,

Ay
Anonymous 17 year
Ay,

You can use the VBScript Timer function to check when you want to transition into a new "state". Something along the lines of

if GetVariable("state_timer") = "0" then
  SetVariable "state_timer", Timer()
end if

state = GetVariable("state")

select case state
  case 0:
    if (Timer() - GetVariable("state_timer")) > 10 then
      SetVariable "state", 1
    else
      ' perhaps set other things while waiting for the next state
    end if
  case 1:
  ' next state
end select

Since you are already in a "loop" in the VBscript you just need to know when to transition onto the next state based on the time. This state dictates what you do in each execution.

STeven.
Ay from United Kingdom  [3 posts] 17 year
Thank you STeven,

I just tried it.
but the state_timer showed 72255.98 and it's never changed.
What does it mean by "if GetVariable("state_timer") = "0" then
"?

Best regards,

Ay
Anonymous 17 year
It will not change ... that's the point cause you want to compare it to the current time specified by Timer()

state_timer is a snapshot (a bookmark) in time that you can compare the current time too.

if GetVariable("state_timer") = "0" then

is used to initialize the state_timer variable.

Be sure to have a look through other posts in the forum for these kinds of examples ... this is a common topic that comes up.

Note that the provided code is a skeleton on which to continue your experiments ... it will not do anything as is but is merely and example on how to create state based transitions when you are inside a loop.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index