loading
 
Need help touching up my code!
Jonnyboy323 from United States  [13 posts]
8 years
Ok well as stated in previous posts, I have modded a usb missile launcher into a airsoft turret. The objective of the code is to find the target isolated, move to near the center of the screen, then oscillate fire on and off to prevent over heating and excessive bb use.

This code DOES NOT WORK! I have the right idea but cant get it working,

move = 0
size = GetVariable("COG_BOX_SIZE")

  if size > 10 then

    cogx = GetVariable("cog_x")
    cogy = GetVariable("cog_y")

      if cogx < 130 then
       move = move OR 4
      else
      if cogx > 222 then
         move = move OR 8
      end if
      end if

      if cogy < 101 then
        move = move OR 2
      else
      if cogy > 181 then
        move =  move OR 1
      end if
      end if

  end if

    if cogx <197 and cogx > 150  and cogy < 168 and cogy > 121 then

     step = 0
     period = 500
     period2 = 1000

    step = GetVariable("step")
      if step = 0 then
          SetVariable "move", 16
          SetVariable "step", 1
          SetTimedVariable "step", 2, period
      else
      if step = 2 then
       SetVariable "move", 0
       SetVariable "step", 3
       SetTimedVariable "step", 0, period2
      end if
    end if

  end if

SetVariable "move", move

I would love any input and have also included the roborealm file.
Thank You!

Jon

program.robo
Anonymous 8 years
Jon,

Close .. but your use of the variable "move" and the SetVariable "move" were conflicting each other ... in essence one was overwriting the other. The last statement you have in the VBScript is SetVariable "move", move which will overwrite any previous SetVariable "move" function calls.

We rearranged your script a little and it does appear to oscillate the firing correctly once the red object is in the center of the image.

STeven.
program.robo
Jonnyboy323 from United States  [13 posts] 8 years
Thank you so much. I knew it was the last line but im still trying to learn VBScript. Thanks for all your help!
Jon

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