LivioBrunner

MenuAPI v.1.0

May 20th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local rows = {}
  2. local rowCounter = 0
  3. os.loadAPI("touchpoint")
  4.  
  5. local margin = 2
  6. local height = 2
  7.  
  8. local t = touchpoint.new("top")
  9. local w, h = term.getSize()
  10.  
  11.  
  12. function addRow(column)
  13.     rows[rowCounter] = column
  14.     rowCounter = rowCounter + 1
  15. end
  16. function addButton(label, row, column, width, func, color1, color2)
  17.     marginLeft = column / rows[row] * w + margin
  18.     marginTop = row * height + margin * row + margin
  19.     width = ((width / rows[row]) * (w - (rows[row] + 1) * margin)) + marginLeft
  20.     t:add(label, func, math.floor(marginLeft), math.floor(marginTop),math.floor(width), math.floor(height + marginTop), color1, color2)
  21. end
  22. function draw()
  23.   t:draw()
  24.   while true do
  25.     local event, p1 = t:handleEvents(os.pullEvent())
  26.     if event == "button_click" then
  27.     term.clear()
  28.     end
  29.   end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment