I have written some code for this.Is this going to work or does the sleep cause the whole computer to hang?
oldState = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false}
newState = {}
count = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
computer = 1
sending = coroutine.create(SendCount)
coroutine.resume(sending)
while true do
colorvalue = rs.getBundledInput("back")
newState[0] = colors.test(colorvalue,colors.white)
newState[1] = colors.test(colorvalue,colors.orange)
newState[2] = colors.test(colorvalue,colors.magenta)
newState[3] = colors.test(colorvalue,colors.lightblue)
newState[4] = colors.test(colorvalue,colors.yellow)
newState[5] = colors.test(colorvalue,colors.lime)
newState[6] = colors.test(colorvalue,colors.pink)
newState[7] = colors.test(colorvalue,colors.gray)
newState[8] = colors.test(colorvalue,colors.lightgray)
newState[9] = colors.test(colorvalue,colors.cyan)
newState[10] = colors.test(colorvalue,colors.purple)
newState[11] = colors.test(colorvalue,colors.blue)
newState[12] = colors.test(colorvalue,colors.brown)
newState[13] = colors.test(colorvalue,colors.green)
newState[14] = colors.test(colorvalue,colors.red)
newState[15] = colors.test(colorvalue,colors.black)
for i = 0, 15, 1 do
if oldState[i] == false and newState[i] == true then
count[i] = count[i] + 1;
end
end
oldState = newState
newState = {}
os.sleep(100)
end
function SendCount()
while true do
for i = 0, 15, 1 do
if count[i] != 0 then
http.request("url?item=".. i + 1 .."&computer="..computer.."&count="..count[i] )
end
end
count = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
os.sleep(10000);
end
end