|
Variable time limit? Jonnyboy323 from United States [13 posts] |
15 year
|
How would i tell roborealm to do something for x amount of time. Example, Tell move=16 for 5 seconds. Then wait 5 Seconds.
|
|
|
Anonymous |
15 year
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
Ok thanks. I'm still a little confused though. Let me explain my situation.
When the variable "move" = 16 i need it to turn of after 5 seconds then go back to the top of the script and check if "move" is still 16. If so turn back on for 5 seconds and so on. If not then stay off.
Thank you so much for your help so far :D
|
|
|
Anonymous |
15 year
|
Jonny,
Perhaps you could include what you have so far in your script? When you say check if move is still 16 are you expecting something else to modify that variable outside of the VBscript? Perhaps someone pressing a button or something?
You would "turn off" move by setting it to 0 ... thus checking if it is still 16 does not make much sense as you'd be the one that would change it.
I think you may be looking for some action that is not best described by talking about the specific values. Perhaps you could explain what you are trying to do at a higher level?
STeven.
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
Ok Sure
So i have done this mod, http://www.inventgeek.com/Projects/usbairsoftturret/Overview.aspx
to my missile launcher. But I did not hook it up so it stops automatically. So in RR i didn't have it fire for either the single fire or the primed fire. So as long as "move" is equal to 16 it fires. The missile launcher is not very precise on aiming so i have it "shoot", 16, only when the cog of the red object is very close to the center. But i dont want it to keep firing at the red object, i want it to once it sees the red object, moves to it, its in the center, then it should fire but only for 5 seconds, then wait 5 seconds with no shooting. Then check if the object is still present on the camera. If so, then move and fire again. So i'm trying to figure out how to add a way to fire only for 5 seconds. Then wait, then fire again if needed.
Thank you so much for helping become a RR expert :)
Jon program.robo
|
|
|
Anonymous |
15 year
|
Jonny,
Ok, that makes sense. Attached is a robofile which I think will work. Basically you are creating a "paused" variable that is set once firing starts. That variable basically disables anything else from happening until the pause variable becomes not 1 (i.e. it is set to 0 again). This variable is first set to 1 when firing starts and then uses the SetTimedVariable function to set the variable to 0 in 5000 ms or 5 seconds. Thus RR will change that variable in 5 seconds and allow the VBScript function to continue as normal.
Does that make sense?
STeven.
program.robo
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
Ok yes that makes sense. Except i have two questions. In the script after it changes paused to 1, isnt supposed to go to zero? Also what do i need to add to make it turn off the shooting for 5 seconds even if its on the target?
Thanks again!
Jon
|
|
|
Anonymous |
15 year
|
Jon,
No, it should only go to zero after the end of firing ... otherwise if it goes to zero the firing will stop (or at least I think it does ...).
You'd have to use another variable that keeps track of once firing is started set it to 1 and only zero it when a non-fire move is made. Then use a conditional around the firing to check that this variable is 0 otherwise you'd ignore the move=16 setting.
Keep in mind that using
variable=value
will be valid until the end of the VBScript ... once the script is called again that variable WILL be 0 unless you use
variable = GetVariable("variable")
SetVariable "variable", value
which will preserve the value through successive loops of the pipeline. Remember that you are within a big loop but not one that ensure that variables retain their values.
STeven.
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
When i run the program it never visibly goes to zero although it works. The only problem now is if the center stays on the target it keeps firing which i dont want it to do. But as you explain above it fixes that but how to i incorporate that into the vbscript?
Jon
|
|
|
Anonymous |
15 year
|
Jon,
Perhaps you can include the robofile again so that we can keep track of how the VBScript is evolving? The above description is in theory how you could change the VBScript to incorporate this behavior ... or did you not make any changes?
STeven.
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
I have not made changes to your script yet. Because its a airsoft gun, i just dont want it firing constantly. More like long bursts
Jon
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
Well this has died for a while but im rekindling my idea. Like i have said above, what would be the best way to make it fire for 3 seconds, wait 3 seconds, and then fire for 3 and so on?
|
|
|
Anonymous |
15 year
|
Jon,
Again, including the robofile that you currently have will help progress this along as we can't guess what you've been able to accomplish without seeing anything. The responses in this thread are still valid. Have you had any success with any of the above suggestions?
STeven.
|
|
|
Jonnyboy323 from United States [13 posts] |
15 year
|
Ok well heres what i have so far. Its not working to well i think because of the last line, feel free to dig through the code and fix some thing because i seem to be at a bit of a rock and a hard place. I just want it to space out the time its firing program.robo
|
|