os.loadAPI("btn")
m = peripheral.wrap("top")
m.setBackgroundColor(colors.white)
m.clear()
m.setTextScale(0.5)

function fillTable()
   btn.setTable("Coca-Cola", ONE, 3,13,5,6)
   btn.setTable("Strawberry", TWO, 3,13,10,11)
   btn.setTable("Lemon-Lime", TRE, 3,13,15,16)
   btn.setTable("Cool Grape", FOR, 3,13,20,21)
   btn.screen()
end

function getClick()
   event,side,x,y = os.pullEvent("monitor_touch")
   btn.checkxy(x,y)
end

function ONE()
   btn.flash("Coca-Cola")
   rs.setOutput("back", true)
   sleep(0.5)
   rs.setOutput("back", false)
end

function TWO()
   btn.flash("Strawberry")
   rs.setOutput("left", true)
   sleep(0.5)
   rs.setOutput("left", false)
end   

function TRE()
  btn.flash("Lemon-Lime")
  rs.setOutput("right", true)
  sleep(0.5)
  rs.setOutput("right", false)
end

function FOR()
  btn.flash("Cool Grape")
  rs.setOutput("bottom", true)
  sleep(0.5)
  rs.setOutput("bottom", false)
end
   
         
fillTable()
m.setCursorPos(1,1)
m.setBackgroundColor(colors.white)
m.setTextColor(colors.black)
m.write("CHOOSE FLAVOR:")

while true do
term.redirect(m)
m.setTextColor(colors.white)
paintutils.drawLine(3,6,13,6,colors.brown)
paintutils.drawLine(3,11,13,11,colors.pink)
paintutils.drawLine(3,16,13,16,colors.lime)
paintutils.drawLine(3,21,13,21,colors.purple)

   getClick()
end
