Advertisement
Guest User

startup

a guest
Aug 22nd, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. function paintMon(side, color)
  2.   local mon = peripheral.wrap(side)
  3.   term.redirect(mon)
  4.   local x,y = term.getSize()
  5.    
  6.   for i=0, x do
  7.     for j=0, y do
  8.       paintutils.drawPixel(i,j,color)
  9.     end
  10.   end
  11.  
  12.   term.restore()
  13. end
  14.  
  15. function writeMon(side, text)
  16.   local mon = peripheral.wrap(side)
  17.   mon.setTextScale(0.5)
  18.   term.redirect(mon)
  19.   term.clear()
  20.  
  21.   local x,y = term.getSize()
  22.   term.setCursorPos(math.floor(x/2 - text:len()/2 + 0.5), math.floor(y/2 + 0.5 ))
  23.   term.setTextColor(colors.white)
  24.   term.write(text)
  25.  
  26.   term.restore()  
  27. end  
  28.  
  29. local input = redstone.getInput("bottom")
  30.  
  31. while true do
  32.   term.setCursorBlink(false)
  33.   if input==true then
  34.     paintMon("left",colors.red)
  35.     writeMon("left","Aux power: OFF")
  36.   else
  37.     paintMon("left",colors.green)
  38.     writeMon("left","Aux power: ON")
  39.   end
  40.    
  41.   local event,side,x,y = os.pullEvent("monitor_touch")
  42.  
  43.   if tostring(side)=="left" then
  44.     if input==true then
  45.       redstone.setOutput("bottom",false)
  46.       input=false
  47.     else
  48.       input=true
  49.       redstone.setOutput("bottom",true)
  50.     end
  51.   end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement