os.loadAPI("button") m = peripheral.wrap("right") m.clear() local time = 15 local enabled = false local count = 0 local dir = 0 function pulse(color) rs.setBundledOutput("back", color) sleep(1) rs.setBundledOutput("back", 0) end local function getDir() if dir == 1 then return "Forward" elseif dir == 2 then return "Backward" elseif dir == 3 then return "Left" elseif dir == 4 then return "Right" else return "None" end end function status() if enabled then m.setBackgroundColor(colors.green) else m.setBackgroundColor(colors.red) end m.setCursorPos(2,2) m.write(" ") m.setCursorPos(2,3) m.write(" ") m.setCursorPos(2,4) m.write(" ") w,h = m.getSize() if enabled then m.setCursorPos((w-string.len("Status : Enabled"))/2+1, 2) m.write("Status : Enabled") else m.setCursorPos((w-string.len("Status : Disabled"))/2+1, 2) m.write("Status : Disabled") end m.setCursorPos((w-string.len("Count : "..count))/2+1, 3) m.write("Count : "..count) m.setCursorPos((w-string.len("Direction : "..getDir(dir)))/2+1, 4) m.write("Direction : "..getDir(dir)) end function fillTable() button.setTable("Forward", forward, 10,20,6,6) button.setTable("Left", left, 2,12,8,8) button.setTable("Right", right, 18,28,8,8) button.setTable("Back", back, 10,20,10,10) button.screen() end function getClick() event,side,x,y = os.pullEvent("monitor_touch") button.checkxy(x,y) end function forward() button.toggleButton("Forward") enabled = true dir = 1 count = 10 while count > 0 do pulse(colors.red) count = count - 1 status() sleep(time) end button.toggleButton("Forward") enabled = false dir = 0 status() end function back() button.toggleButton("Back") enabled = true dir = 2 count = 100 while count > 0 do pulse(colors.green) count = count - 1 status() sleep(time) end button.toggleButton("Back") enabled = false dir = 0 status() end function test3() print("Test3") end function test4() print("Test4") end fillTable() status() while true do getClick() end