Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function contains(b,x,y)
- if (b[1]<=x and x<=b[2]) and (b[3]<=y and y<=b[4]) then
- return true
- else
- return false
- end
- end
- local m = peripheral.wrap("left")
- local m2 = peripheral.wrap("top")
- m2.clear()
- local paintFlag = true
- term.redirect(m)
- term.setBackgroundColor(colors.white)
- term.clear()
- local cols = {
- colors.red,
- colors.green,
- colors.blue,
- colors.brown,
- colors.yellow,
- colors.magenta,
- colors.cyan,
- colors.orange,
- colors.white
- }
- local btns = {
- [1]={1,10,18,12,colors.black},
- [2]={1,11,2,12,colors.red},
- [3]={3,11,4,12,colors.green},
- [4]={5,11,6,12,colors.blue},
- [5]={7,11,8,12,colors.brown},
- [6]={9,11,10,12,colors.yellow},
- [7]={11,11,12,12,colors.magenta},
- [8]={13,11,14,12,colors.cyan},
- [9]={15,11,16,12,colors.orange},
- [10]={17,11,19,11,colors.white},
- }
- while true do
- paintFlag = true
- m2.setCursorPos(1,1)
- for k, b in ipairs(btns) do
- paintutils.drawFilledBox(b[1],b[2],b[3],b[4],b[5])
- end
- local e = {os.pullEvent()}
- m2.write(e[3])
- m2.write(e[4])
- if (e[1] == "monitor_touch") then
- for k, b in ipairs(btns) do
- if (contains(b,e[3],e[4])==true) then
- c = cols[k]
- m2.setCursorPos(1,2)
- m2.write()
- paintFlag=false
- end
- end
- if(paintFlag) then
- paintutils.drawPixel(e[3],e[4],c)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement