Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local gray = 0x47494C
- local black = 0x000000
- local mon = component.gpu
- mon.setResolution(58,18)
- --Page Variable
- local page
- --Irrelevant variables
- local a = {}
- local w, h = mon.getResolution()
- --
- --Irrelevant Functions
- function centerText(mon, text, height)
- local x2, y2 = mon.getResolution()
- mon.set( x2/2 - (#text / 2) + 1, height, text)
- end
- function clear()
- mon.fill(1,1,w,h, " ")
- end
- function tableLength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- --
- --Draw Page 1 ***
- function pageOne()
- centerText(mon, "Page 1", 1)
- mon.setBackground(gray)
- mon.fill(w/2 - 5, h/2 - 1, 12, 3, " ")
- centerText(mon, "Button 1", h/2)
- mon.setBackground(black)
- local aLength = tableLength(a)
- lh = h/2 + 3
- while aLength > 0 and lh < 19 do
- centerText(mon, tostring(a[aLength]), lh)
- lh = lh + 1
- aLength = aLength - 1
- end
- end
- --Drag Page Two ***
- function pageTwo()
- centerText(mon, "Page 2", 1)
- mon.setBackground(gray)
- mon.fill(w/2 - 5, h/2 - 1, 12, 3, " ")
- centerText(mon, "Button 2", h/2)
- mon.setBackground(black)
- end
- --Draw Page One and set Page = "page1" ***
- clear()
- pageOne()
- page = "page1"
- while true do
- --if page then draw corresponding Page ***
- if page == "page1" then
- pageOne()
- elseif page == "page2" then
- pageTwo()
- end
- --Irrelevant os.exit when table reaches end of screen
- if lh == 19 then
- os.exit()
- end
- local touch, _, x, y = event.pull("touch")
- --Page 1 Handle ***
- if page == "page1" and (x >= w/2 - 5 and x <= (w/2 - 5) + 11) and (y >= h/2 - 1 and y <= h/2 + 1) then
- mon.set(4, 10, "Event 1")
- table.insert(a, "X")
- page = "page2"
- end
- --Page 2 Handle ***
- if page == "page2" and (x >= w/2 - 5 and x <= (w/2 - 5) + 11) and (y >= h/2 - 1 and y <= h/2 + 1) then
- mon.set(4, 45, "Event 2")
- page = "page1"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement