loading
 
cog box size variable never resets to null?
Anonymous
15 year
This is more a vb script question, how can I get a bunch of variables to reset after the cog module is no longer displaying on screen, basically after cog_box_size should be no existant, but it seems to stay its last value before it stopped tracking?
Anonymous 15 year
SetVariable "L", L

i figured it out using Movement percentage... my variables still dont work right and I'm hoping its just my understanding of the the setvariable command or something?

SetVariable "R", R

SetVariable "M", M
l= GetVariable("L")
r= GetVariable("R")
m = GetVariable("M")
move = GetVariable("MOVEMENT_PERCENT")

' get the size (width or height) of the current bounding box
size = GetVariable("COG_BOX_SIZE")

' if it is equal to "" then no object was detected
if size <> "" then

' get the horizontal center of gravity
cogX = GetVariable("COG_X")



if cogX < 20 then
l = 1
elseif cogX > 300 then
r = 1
elseif 150 < cogX < 170 then
m = 1

end if


if move = 0 then
SetVariable "L", 0

SetVariable "R", 0

SetVariable "M", 0
end if
end if
Anonymous 15 year
sorry to post so many times

as of now when movement is seen on screen all the variables become 1 at the same time and then turn to 0 all together when movement =0
Anonymous 15 year
I think the variables are getting cleared but you are not keeping yours in sync. You should not need the movement module with the following code

l= GetVariable("L")
r= GetVariable("R")
m = GetVariable("M")

' get the size (width or height) of the current bounding box
size = GetVariable("COG_BOX_SIZE")

' if it is equal to "" then no object was detected
if size <> "" then

  ' get the horizontal center of gravity
  cogX = GetVariable("COG_X")

  if cogX < 20 then
    l = 1
  elseif cogX > 300 then
    r = 1
  elseif 150 < cogX < 170 then
    m = 1
  end if

  SetVariable "L", l
  SetVariable "R", r
  SetVariable "M", m

else
  SetVariable "L", 0
  SetVariable "R", 0
  SetVariable "M", 0
end if

Basically if size = "" then you need to also null out your variables. Remember that without using the SetVariable routine your variables will not change ... when you use l,r,m in the VBScript module they are only local to that module and are not "saved" to other parts of RoboRealm.

STeven.
Jeff Sampson from United States  [1 posts] 15 year
For anyone else trying to get this to work, I had to change the following from:

' if it is equal to "" then no object was detected
if size <> "" then

to:

' if it is equal to 0 then no object was detected
if size <> 0 then

At least that is what I had to do to get it to work.

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