Advertisement
Guest User

test

a guest
Feb 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. local component = require("component")
  2. local serialization = require("serialization")
  3. local event = require("event")
  4. local os = require("os")
  5. local thread = require("thread")
  6. local unicode = require("unicode")
  7. local gpu = component.gpu
  8. local modem = component.modem
  9.  
  10. local black = 0x000000
  11. local white = 0xFFFFFF
  12. local gray  = 0x212121
  13. local blue  = 0x0000FF
  14.  
  15.  
  16. local gui1 = thread.create(function()
  17.     local x = 10
  18.     local y = 5
  19.     local w = 40
  20.     local h = 15
  21.     local title = "test"
  22.     while true do
  23.         gpu.setBackground(gray)
  24.         gpu.setForeground(white)
  25.         gpu.fill(x, y, w, h, " ")
  26.         gpu.set(x, y, unicode.char(0x2554))
  27.         gpu.set(x+w-1, y, unicode.char(0x2557))
  28.         gpu.set(x, y+h-1, unicode.char(0x255A))
  29.         gpu.set(x+w-1, y+h-1, unicode.char(0x255D))
  30.         gpu.fill(x+1, y, w-2, 1, unicode.char(0x2550))
  31.         gpu.fill(x+1, y+h-1, w-2, 1, unicode.char(0x2550))
  32.         gpu.fill(x, y+1, 1, h-2, unicode.char(0x2551))
  33.         gpu.fill(x+w-1, y+1, 1, h-2, unicode.char(0x2551))
  34.         local t = unicode.char(0x2561) .. title .. unicode.char(0x255e)
  35.         gpu.set(x+(w/2) - (string.len(t)/2), y, t)
  36.         gpu.setBackground(blue)
  37.         gpu.setForeground(white)
  38.         gpu.set(x+(w/2)-4, y+h-2, "[close]")
  39. --        closeButton[0] = x+(w/2)-4
  40. --        closeButton[1] = y+h-2
  41.        
  42.         local id1, _, x1, y1, b1 = event.pull("touch")
  43.         if id1 ~= nil then
  44.             gpu.setBackground(blue)
  45.             gpu.setForeground(white)
  46.             gpu.set(1, 1, "1 : " .. x1 .. " " .. y1 .. " " .. b1)
  47.         end
  48.     end
  49. end)
  50.    
  51.  
  52. local gui2 = thread.create(function()
  53.     local x = 30
  54.     local y = 15
  55.     local w = 30
  56.     local h = 10
  57.     local title = "test2"
  58.     while true do
  59.         gpu.setBackground(gray)
  60.         gpu.setForeground(white)
  61.         gpu.fill(x, y, w, h, " ")
  62.         gpu.set(x, y, unicode.char(0x2554))
  63.         gpu.set(x+w-1, y, unicode.char(0x2557))
  64.         gpu.set(x, y+h-1, unicode.char(0x255A))
  65.         gpu.set(x+w-1, y+h-1, unicode.char(0x255D))
  66.         gpu.fill(x+1, y, w-2, 1, unicode.char(0x2550))
  67.         gpu.fill(x+1, y+h-1, w-2, 1, unicode.char(0x2550))
  68.         gpu.fill(x, y+1, 1, h-2, unicode.char(0x2551))
  69.         gpu.fill(x+w-1, y+1, 1, h-2, unicode.char(0x2551))
  70.         local t = unicode.char(0x2561) .. title .. unicode.char(0x255e)
  71.         gpu.set(x+(w/2) - (string.len(t)/2), y, t)
  72.         gpu.setBackground(blue)
  73.         gpu.setForeground(white)
  74.         gpu.set(x+(w/2)-4, y+h-2, "[close]")
  75. --        closeButton[0] = x+(w/2)-4
  76. --        closeButton[1] = y+h-2
  77.        
  78.         local id1, _, x1, y1, b1 = event.pull("touch")
  79.         if id1 ~= nil then
  80.             gpu.setBackground(blue)
  81.             gpu.setForeground(white)
  82.             gpu.set(1, 2, "2 : " .. x1 .. " " .. y1 .. " " .. b1)
  83.         end
  84.     end
  85. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement