hevohevo

gate

Mar 22nd, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. os.loadAPI("h2touchpanel")
  2.  
  3.  
  4. FLINT = 1
  5. LID = 2
  6.  
  7. function on()
  8.   turtle.select(FLINT)
  9.   turtle.up()
  10.   turtle.turnRight()
  11.   turtle.forward()
  12.   turtle.turnLeft()
  13.   turtle.select(FLINT)
  14.   turtle.place()
  15.   turtle.turnLeft()
  16.   turtle.forward()
  17.   turtle.turnRight()
  18.   turtle.down()
  19. end
  20.  
  21. function off()
  22.   turtle.select(LID)
  23.   turtle.up()
  24.   turtle.dig()
  25.   turtle.place()
  26.   turtle.down()
  27. end
  28.  
  29. local btnCfg = {}
  30. btnCfg[1] = {name="ON", cmd=on}
  31. btnCfg[2] = {name="OFF", cmd=off}
  32.  
  33. panelCfg = {topPos=2,scale=1, bgPattern={colors.blue, colors.red}}
  34.  
  35.  
  36. while true do
  37.   sleep(1)
  38.   local mon = peripheral.wrap("front")
  39.   local panel = h2touchpanel.makePanel(btnCfg, 1, 2, mon, panelCfg)
  40.   panel:draw()
  41.   mon.setCursorPos(1,1)
  42.   mon.setBackgroundColor(colors.gray)
  43.   mon.write(string.format("%d", turtle.getFuelLevel()))
  44.   local event, button = panel:pullButtonPushEvent()
  45.  
  46.   panel:drawPushedButtonEffect(button)
  47.   button:evalCmd()
  48. end
Advertisement
Add Comment
Please, Sign In to add comment