Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local component = require("component")
- local Button = require("button")
- local gpu = component.gpu
- gpu.setResolution(160, 50)
- -- gpu.setResolution(80,25)
- local w, h = gpu.getResolution()
- local backgroundColor = 0x696969
- local s = {}
- local buttons = {}
- function fillBackground(color)
- gpu.setForeground(0x000000)
- gpu.setBackground(color)
- gpu.fill(1, 1, w, h, " ")
- end
- function calculateSize()
- s.buttonWidth = math.floor(w/3)
- s.buttonHeight = math.floor(h/5)
- s.buttonColumnGap = math.floor(w/8)
- s.buttonRowGap = math.floor(h/15)
- end
- --only on startup
- function start()
- fillBackground(backgroundColor)
- calculateSize()
- table.insert(buttons, Button:new{x=s.buttonColumnGap, y=s.buttonRowGap, width=s.buttonWidth, height=s.buttonHeight,
- borderColor=0x4b4b4b, fillColor=0x5a5a5a, text="Gravel"}
- )
- table.insert(buttons, Button:new{x=s.buttonColumnGap, y=s.buttonRowGap*2+s.buttonHeight, width=s.buttonWidth, height=s.buttonHeight,
- borderColor=0xffff80, fillColor=0xffffc0, text="Sand"}
- )
- table.insert(buttons, Button:new{x=s.buttonColumnGap, y=s.buttonRowGap*3+s.buttonHeight*2, width=s.buttonWidth, height=s.buttonHeight,
- borderColor=0xffffc0, fillColor=0xf0f0f0, text="Dust"}
- )
- table.insert(buttons, Button:new{x=w-s.buttonColumnGap-s.buttonWidth, y=s.buttonRowGap, width=s.buttonWidth, height=s.buttonHeight,
- borderColor=0x330000, fillColor=0x332400, text="Soulsand"}
- )
- table.insert(buttons, Button:new{x=w-s.buttonColumnGap-s.buttonWidth, y=s.buttonRowGap*2+s.buttonHeight, height=s.buttonHeight,
- borderColor=0x660000, fillColor=0x990000, text="Netherrack"}
- )
- table.insert(buttons, Button:new{x=w-s.buttonColumnGap-s.buttonWidth, y=s.buttonRowGap*3+s.buttonHeight*2, height=s.buttonHeight,
- borderColor=0xccc0ff, fillColor=0xccc0db, text="Endstone"}
- )
- for i = 1, #buttons do
- buttons[i]:draw()
- end
- end
- --actions when running
- function update()
- repeat
- local ev, _, x, y, user = event.pull()
- if ev == "touch" then
- print(buttons[1]:checkClick(x, y))
- end
- until false
- end
- start()
- update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement