Advertisement
dzaima

computercraft

Jan 17th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. local mMon = peripheral.wrap( "top" )
  2. mButtons = {{2, 2, "Gate", colors.red, colors.green, 4},{2,5,"Floor",colors.red,colors.green, 5}}
  3. isOn = {0,0}
  4. while true do
  5.     event, side, xP, yP = os.pullEvent("monitor_touch")
  6.     mMon.setBackgroundColor(colors.black)
  7.     mMon.clear()
  8.     for count1, cBA in ipairs(mButtons) do
  9.  
  10.         if yP >= cBA[2] and yP <= cBA[2]+1 and xP+2 > cBA[1] and xP < (cBA[1]+cBA[6]) then
  11.             if isOn[count1] == 0 then
  12.                 isOn[count1] = 1
  13.             else
  14.                 isOn[count1] = 0
  15.             end
  16.         end
  17.         mMon.setBackgroundColor(cBA[4+isOn[count1]])
  18.         mMon.setCursorPos(cBA[1], cBA[2])
  19.         mMon.write (cBA[3])
  20.        
  21.     end
  22.     redstone.setBundledOutput("bottom", tonumber(table.concat(isOn, ""),2))
  23. end
  24. --table.concat(isOn, "")
  25. --mMon - monitor
  26. --mButtons - array of buttons
  27. --cBA - current butrton array
  28.  
  29.  
  30. --[[    mMon.clear
  31.     mMon.setCursorPos(1, 1)
  32.     mMon.write ("x:" .. toString (xP))
  33.     mMon.setCursorPos(1, 2)
  34.     mMon.write ("y:" .. toString (yP))
  35.    
  36. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement