Advertisement
Guest User

MonitorTest

a guest
Nov 6th, 2013
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1.  
  2. os.loadAPI("touchpoint")
  3. rednet.open("bottom")
  4.  
  5. local page1 = touchpoint.new("top")
  6. local page2 = touchpoint.new("top")
  7. local page3 = touchpoint.new("top")
  8.  
  9. local page4 = touchpoint.new("top")
  10. local page5 = touchpoint.new("top")
  11.  
  12. local t
  13.  
  14. function turtleMsg(name, extra)
  15.     extra = extra or nil
  16.     if extra ~= nil then
  17.         if extra == "fuelLevel" then
  18.             rednet.send(3, tostring(name))
  19.             local id, msg, dst = rednet.receive()
  20.             page4:rename("Fuel Level", tostring(msg))
  21.             t = page4
  22.             t:draw()
  23.             os.sleep(1.75)
  24.             page4:rename(tostring(msg), "Fuel Level")
  25.             t = page3
  26.             t:draw()
  27.         else
  28.             rednet.send(3, tostring(name))
  29.             local id, msg, dst = rednet.receive()          
  30.             page5:rename("Refueled", (tostring(msg)))
  31.             t = page5
  32.             t:draw()
  33.             os.sleep(1.5)
  34.             page5:rename((tostring(msg)), "Refueled")
  35.             t = page3
  36.             t:draw()
  37.         end
  38.  
  39.     else
  40.         page3:toggleButton(name)
  41.         rednet.send(3, tostring(name))
  42.         os.sleep(.75)
  43.         page3:toggleButton(name)
  44.     end
  45. end
  46.  
  47. function rsRight()
  48.     page2:toggleButton("Activate Right")
  49.     rs.setOutput("right", not rs.getOutput("right"))
  50. end
  51.  
  52. function rsLeft()
  53.     page2:toggleButton("Activate Left")
  54.     rs.setOutput("left", not rs.getOutput("left"))
  55. end
  56.  
  57. function redMenu()
  58.     t = page2
  59. end
  60.  
  61. function mainMenu()
  62.     t = page1
  63. end
  64.  
  65. function turtleMenu()
  66.     t = page3
  67. end
  68.  
  69. function callButton(name)
  70.     if t.buttonList[name].func ~= nil then
  71.            t.buttonList[name].func()
  72.     end
  73. end
  74.  
  75. do
  76.     page1:add("Main Menu", nil, 15, 35, 2, 5, colors.black, colors.black)
  77.     page1:add("Redstone",redMenu, 5, 20, 11, 14)
  78.     page1:add("Turtle",turtleMenu, 30, 45, 11, 14)
  79.  
  80.     page2:add("Activate Left", rsLeft, 5, 20, 11, 14)
  81.     page2:add("Activate Right", rsRight, 30, 45, 11, 14)
  82.     page2:add("Secret", wireless, 20, 30, 18, 21)
  83.     page2:add("Main Menu",mainMenu, 15, 35, 3, 6)
  84.  
  85.     page3:add("Go Forward",function() turtleMsg("Go Forward") end, 5, 20, 11, 14)
  86.     page3:add("Dig",function() turtleMsg("Dig") end, 30, 45, 11, 14)
  87.     page3:add("Turn Left",function() turtleMsg("Turn Left") end, 5, 20, 16, 19)
  88.     page3:add("Turn Right",function() turtleMsg("Turn Right") end, 30, 45, 16, 19)
  89.     page3:add("Get Fuel Level", function() turtleMsg("Get Fuel Amount", "fuelLevel") end, 5, 20, 21, 24)
  90.     page3:add("Refuel", function() turtleMsg("Refuel", "extraRefuel") end, 30, 45, 21, 24)
  91.     page3:add("Main Menu",mainMenu, 15, 35, 3, 6)
  92.  
  93.     page4:add("Fuel Level", nil, 15, 35, 13, 16, colors.black, colors.black)
  94.     page5:add("Refueled", nil, 5, 45, 13, 16, colors.black, colors.black)
  95.  
  96. end
  97.  
  98. t = page1
  99. while true do
  100.     t:draw()
  101.     local event, p1 = t:handleEvents(os.pullEvent())
  102.     if event == "button_click" then
  103.         callButton(p1)
  104.     end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement