Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local gpu = component.gpu
- local redstone = component.redstone
- local unicode = require("unicode")
- local term = require("term")
- function funcbutton1()
- redstone.setOutput(3, 1)
- os.sleep(1)
- redstone.setOutput(3, 0)
- end
- function funcbutton2()
- redstone.setOutput(0, 1)
- os.sleep(1)
- redstone.setOutput(0, 0)
- end
- buttons = {button1 = {x = 1, y = 1, width = 10 , heigh = 5, text = "ясно", color = 0x0000ff, func = funcbutton1},
- button2 = {x = 12, y = 1, width = 10, heigh = 5, text = "дождь", color = 0x0000ff, func = funcbutton2}
- }
- function drawbuttons()
- for k, v in pairs(buttons) do
- gpu.setBackground(v.color)
- gpu.fill(v.x, v.y, v.width, v.heigh, " ")
- gpu.set(v.x + v.width/ 2 - unicode.wlen(v.text) / 2, v.y + v.heigh / 2, v.text)
- end
- --gpu.setbackground(0x000000, false)
- end
- function ev()
- while true do
- local _,_,x,y = event.pull("touch")
- for k,v in pairs(buttons) do
- if x >= v.x and x < v.x + v.width+2 and y >= v.y and y < v.y + v.heigh then
- v.func()
- end
- end
- end
- end
- term.clear()
- drawbuttons()
- ev()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement