Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require ('component')
- local gpu = component.gpu
- local pe = require ('event').pull
- local W, H = gpu.getResolution()
- local bColor, fColor = 0x000000, = 0xffffff
- local b_color, f_color = gpu.getBackground(), gpu.getForeground()
- local scr = {[1] = '577704fa-54af-4d4b-960d-77ed2c50229a', [2] = '8f607167-d55e-414d-a01e-996e17e629fb', [3] = '09764fde-13a6-48b4-a321-23bdbda184bf'}
- -------------------------------------------------------------------------------------------------------------------------------------
- local tButtons = {
- {
- visible = false, X = W-2, Y = 1, W = 3, H = 3, color = 0xff0000, textColor = 0xffffff, text = 'X',
- action = function()
- gpu.setBackground(b_color)
- gpu.setForeground(f_color)
- gpu.fill(1, 1, W, H, ' ')
- gpu.bind(scr[1])
- os.exit()
- end
- },
- {
- visible = false, X = 35, Y = 3, W = 10, H = 3, color = 0x00ff00, textColor = 0xffffff, text = 'Floor 1',
- action = function()
- gpu.setBackground(b_color)
- gpu.setForeground(f_color)
- gpu.fill(1, 1, W, H, ' ')
- end
- },
- {
- visible = false, X = 35, Y = 8, W = 10, H = 3, color = 0x00ff00, textColor = 0xffffff, text = 'Floor 2',
- action = function()
- gpu.setBackground(b_color)
- gpu.setForeground(f_color)
- gpu.fill(1, 1, W, H, ' ')
- end
- },
- }
- -------------------------------------------------------------------------------------------------------------------------------------
- local function drawButton(n)
- gpu.setBackground(tButtons[n].color)
- gpu.setForeground(tButtons[n].textColor)
- gpu.fill(tButtons[n].X, tButtons[n].Y, tButtons[n].W, tButtons[n].H, ' ')
- gpu.set(tButtons[n].X+(tButtons[n].W/2)-(#tButtons[n].text/2), tButtons[n].Y+(tButtons[n].H/2), tButtons[n].text)
- end
- local function toggleVisible(n)
- if tButtons[n].visible then
- tButtons[n].visible = false
- gpu.setBackground(b_color)
- gpu.fill(tButtons[n].X, tButtons[n].Y, tButtons[n].W, tButtons[n].H, ' ')
- else
- tButtons[n].visible = true
- drawButton(n)
- end
- end
- -------------------------------------------------------------------------------------------------------------------------------------
- gpu.bind(scr[2])
- for i = 1, #tButtons do
- toggleVisible(i)
- end
- while true do
- local tEvent = {pe('touch')}
- for i = 1, #tButtons do
- if tButtons[i].visible then
- if tEvent[3] >= tButtons[i].X and tEvent[3] <= tButtons[i].X+tButtons[i].W and tEvent[4] >= tButtons[i].Y and tEvent[4] <= tButtons[i].Y+tButtons[i].H then
- tButtons[i].action()
- gpu.bind(scr[i])
- for i = 1, #tButtons do
- tButtons[i].visible = false
- toggleVisible(i)
- end
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement