I realized that the boundedIn function wasn't generalized for the table variable, so here is an update:
Code:
table={
['Left']={
['bounds']={
['x1']=0,
['y1']=0,
['x2']=20,
['y2']=20
}
},
['Right']={
['bounds']={
['x1']=220,
['y1']=0,
['x2']=240,
['y2']=20
}
}
}
printIt=false
function boundedIn(x,y,t)
for key,value in pairs(t) do
if x>=value['bounds']['x1'] and x<=value['bounds']['x2'] and y>=value['bounds']['y1'] and y<=value['bounds']['y2'] then return key end
end
return false
end
function onmainloop()
clear(0,0,0)
fillrect(table['Left']['bounds']['x1'],table['Left']['bounds']['y1'],table['Left']['bounds']['x2'],table['Left']['bounds']['y2'],255,0,0)
fillrect(table['Right']['bounds']['x1'],table['Right']['bounds']['y1'],table['Right']['bounds']['x2'],table['Right']['bounds']['y2'],0,0,255)
if printIt~=false then print(100,100,printIt,255,255,0) end
end
function onstylusup(x,y)
printIt=boundedIn(x,y,table)
end