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 sizes = {}
- local buttons = {}
- function fillBackground(color)
- gpu.setForeground(0x000000)
- gpu.setBackground(color)
- gpu.fill(1, 1, w, h, " ")
- end
- function calculateSize()
- sizes.buttonWidth = math.floor(w/3)
- sizes.buttonHeight = math.floor(h/5)
- sizes.buttonColumnGap = math.floor(w/8)
- sizes.buttonRowGap = math.floor(h/15)
- end
- --only on startup
- function start()
- fillBackground(backgroundColor)
- calculateSize()
- -- drawRectangleWithText(6, 4, 70, 10, 0xffffc0, 0xffff80, 1, "Sand")
- -- drawRectangleWithText(6, 17, 70, 10, 0x5a5a5a, 0x4b4b4b, 1, "Gravel")
- -- drawRectangleWithText(6, 30, 70, 10, 0xf0f0f0, 0xffffc0, 1, "Dust")
- -- drawRectangleWithText(86, 4, 70, 10, 0x332400, 0x330000, 1, "Soulsand")
- -- drawRectangleWithText(86, 17, 70, 10, 0x990000, 0x660000, 1, "Netherrack")
- -- drawRectangleWithText(86, 30, 70, 10, 0xccc0db, 0xccc0ff, 1, "Endstone")
- local gravel = Button:new{
- x = sizes.buttonColumnGap,
- y = sizes.buttonRowGap,
- width = sizes.buttonWidth,
- height = sizes.buttonHeight,
- borderColor = 0x4b4b4b,
- fillColor = 0x5a5a5a,
- text = "Gravel"
- }
- local
- table.insert(buttons, gravel)
- buttons[1]:draw()
- end
- --actions when running
- function update()
- repeat
- local ev, _, x, y, user = event.pull()
- if ev == "touch" then
- print(#buttons)
- print(buttons[1]:checkClick(x, y))
- end
- until false
- end
- start()
- update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement