Advertisement
StreamerYT

Untitled

Jan 24th, 2022 (edited)
829
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2.  
  3. local tape = component.tape_drive
  4. local gpu = component.gpu
  5.  
  6. local un = require("unicode")
  7. local computer = require("computer")
  8. local click = require("event").pull
  9.  
  10. local width = 50
  11. local height = 100 / 2
  12.  
  13. local Buttons = {
  14. {
  15.     x = 2, y = 2,
  16.     txt = '▶',
  17.     clr = 0xff00ff,
  18.     action = function() tape.play(); end
  19. }
  20. }
  21.  
  22. function drawButton(n)
  23.   --gpu.setBackground(Buttons[n].fgclr)
  24.   gpu.setForeground(Buttons[n].clr)
  25.   gpu.fill(Buttons[n].x, Buttons[n].y,1,1, ' ')
  26.   gpu.set(Buttons[n].x+1-(un.len(Buttons[n].txt)/2), Buttons[n].y+1, Buttons[n].txt)
  27. end
  28.  
  29.  
  30. while true do
  31.     gpu.setBackground(0xffffff)
  32.     gpu.fill(1, 1, width, height, ' ')
  33.     drawButton(i)
  34.     local event = {click('touch')}
  35.     for i = 1, #Buttons do
  36.         if event[3] == Buttons[i].x and event[4] == Buttons[i].y then
  37.             drawButton(i)
  38.             Buttons[i].action()
  39.         end
  40.     end
  41. end
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement