Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mMon = peripheral.wrap( "top" )
- mButtons = {{2, 2, "Gate", colors.red, colors.green, 4},{2,5,"Floor",colors.red,colors.green, 5}}
- isOn = {0,0}
- while true do
- event, side, xP, yP = os.pullEvent("monitor_touch")
- mMon.setBackgroundColor(colors.black)
- mMon.clear()
- for count1, cBA in ipairs(mButtons) do
- if yP >= cBA[2] and yP <= cBA[2]+1 and xP+2 > cBA[1] and xP < (cBA[1]+cBA[6]) then
- if isOn[count1] == 0 then
- isOn[count1] = 1
- else
- isOn[count1] = 0
- end
- end
- mMon.setBackgroundColor(cBA[4+isOn[count1]])
- mMon.setCursorPos(cBA[1], cBA[2])
- mMon.write (cBA[3])
- end
- redstone.setBundledOutput("bottom", tonumber(table.concat(isOn, ""),2))
- end
- --table.concat(isOn, "")
- --mMon - monitor
- --mButtons - array of buttons
- --cBA - current butrton array
- --[[ mMon.clear
- mMon.setCursorPos(1, 1)
- mMon.write ("x:" .. toString (xP))
- mMon.setCursorPos(1, 2)
- mMon.write ("y:" .. toString (yP))
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement