Tribble1991

Untitled

Jul 31st, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Variables --
  2. mouseWidth = 0
  3. mouseHeight = 0
  4.  
  5. currentMob = "None"
  6. currentFarmStatus = "Off "
  7. currentSpawnerStatus = "Off "
  8.  
  9. --Set turtle connection --
  10. rednet.open("bottom")
  11. Turtle = 17
  12.  
  13.  
  14. --Set monitor properties
  15. monitor = peripheral.wrap("left")
  16. monitor.clear()
  17. monitor.setBackgroundColor((colors.black))
  18.  
  19. monitor.setCursorPos(1,1)
  20.  
  21. w,h=monitor.getSize()
  22.  
  23. --Write spawner status data --
  24. monitor.setBackgroundColor((colors.blue))
  25. monitor.setCursorPos(2,2)
  26. monitor.write("Farm control     ")
  27.  
  28. monitor.setBackgroundColor((colors.blue))
  29. monitor.setCursorPos(2,4)
  30. monitor.write("Status ")
  31.  
  32. --Write farm status data --
  33. monitor.setBackgroundColor((colors.blue))
  34. monitor.setCursorPos(20,2)
  35. monitor.write("Spawner control ")
  36.  
  37. monitor.setBackgroundColor((colors.blue))
  38. monitor.setCursorPos(20,4)
  39. monitor.write("Status ")
  40.  
  41. function setCurrentFarmStatusData()
  42.     if currentFarmStatus == "On  " then
  43.         monitor.setCursorPos(10,4)
  44.         monitor.setBackgroundColor((colors.green))
  45.         monitor.write(currentFarmStatus)
  46.     elseif currentFarmStatus == "Off " then
  47.         monitor.setCursorPos(10,4)
  48.         monitor.setBackgroundColor((colors.red))
  49.         monitor.write(currentFarmStatus)
  50.     end
  51. end
  52.  
  53. function setCurrentSpawnerStatusData()
  54.     if currentSpawnerStatus == "On  " then
  55.         monitor.setCursorPos(28,4)
  56.         monitor.setBackgroundColor((colors.green))
  57.         monitor.write(currentSpawnerStatus)
  58.     elseif currentSpawnerStatus == "Off " then
  59.         monitor.setCursorPos(28,4)
  60.         monitor.setBackgroundColor((colors.red))
  61.         monitor.write(currentSpawnerStatus)
  62.     end
  63.    
  64. end
  65.  
  66. function setCurrentMobData()
  67.     --Write first list of mobs
  68.  
  69.     monitor.setCursorPos(2,6)
  70.     if currentMob == "Enderman" then
  71.         monitor.setBackgroundColor((colors.green))
  72.     else
  73.         monitor.setBackgroundColor((colors.red))
  74.     end
  75.     monitor.write("  Enderman  ")
  76.  
  77.     monitor.setCursorPos(2,8)
  78.     if currentMob == "Skeleton" then
  79.         monitor.setBackgroundColor((colors.green))
  80.         else
  81.         monitor.setBackgroundColor((colors.red))
  82.     end
  83.     monitor.write("  Skeleton  ")
  84.  
  85.     monitor.setCursorPos(2,10)
  86.     if currentMob == "Blaze" then
  87.         monitor.setBackgroundColor((colors.green))
  88.         else
  89.         monitor.setBackgroundColor((colors.red))
  90.     end
  91.     monitor.write("  Blaze     ")
  92.  
  93.     monitor.setCursorPos(2,12)
  94.     if currentMob == "Wisp" then
  95.         monitor.setBackgroundColor((colors.green))
  96.         else
  97.         monitor.setBackgroundColor((colors.red))
  98.     end
  99.     monitor.write("  Wisp     ")
  100.  
  101.     monitor.setCursorPos(2,14)
  102.     if currentMob == "Cow" then
  103.         monitor.setBackgroundColor((colors.green))
  104.         else
  105.         monitor.setBackgroundColor((colors.red))
  106.     end
  107.     monitor.write("  Cow       ")
  108.  
  109.     --Write second list of mobs
  110.     monitor.setCursorPos(16,6)
  111.     if currentMob == "Ghast" then
  112.         monitor.setBackgroundColor((colors.green))
  113.         else
  114.         monitor.setBackgroundColor((colors.red))
  115.     end
  116.     monitor.write("  Ghast     ")
  117.  
  118.     monitor.setCursorPos(16,8)
  119.     if currentMob == "Chicken" then
  120.         monitor.setBackgroundColor((colors.green))
  121.         else
  122.         monitor.setBackgroundColor((colors.red))
  123.     end
  124.     monitor.write("  Chicken   ")
  125.  
  126.     monitor.setCursorPos(16,10)
  127.     if currentMob == "Sheep" then
  128.         monitor.setBackgroundColor((colors.green))
  129.         else
  130.         monitor.setBackgroundColor((colors.red))
  131.     end
  132.     monitor.write("  Sheep     ")
  133.  
  134.     monitor.setCursorPos(16,12)
  135.     if currentMob == "None" then
  136.         monitor.setBackgroundColor((colors.green))
  137.         else
  138.         monitor.setBackgroundColor((colors.red))
  139.     end
  140.     monitor.write("  None      ")
  141.  
  142.     monitor.setCursorPos(16,14)
  143.     if currentMob == "None" then
  144.         monitor.setBackgroundColor((colors.green))
  145.         else
  146.         monitor.setBackgroundColor((colors.red))
  147.     end
  148.     monitor.write("  None      ")
  149. end
  150.  
  151. function changeFarmStatus()
  152.     --Clicked Status --
  153.     if(currentFarmStatus == "On  ") then
  154.         currentFarmStatus = "Off "
  155.         redstone.setOutput("right", false)
  156.     elseif(currentFarmStatus == "Off ") then
  157.         currentFarmStatus = "On  "
  158.         redstone.setOutput("right", true)
  159.     end
  160.     setCurrentFarmStatusData()
  161. end
  162.  
  163. function changeSpawnerStatus()
  164.     --Clicked Status --
  165.     if(currentSpawnerStatus == "On  ") then
  166.         currentSpawnerStatus = "Off "
  167.         rednet.send(Turtle, "Off") 
  168.     elseif(currentSpawnerStatus == "Off ") then
  169.         currentSpawnerStatus = "On  "
  170.         rednet.send(Turtle, "On")  
  171.     end
  172.     setCurrentSpawnerStatusData()
  173. end
  174.  
  175. -- Perform clicked action --
  176. function checkClickPosition()
  177.     --Farm Status --
  178.     if(mouseWidth > 9 and mouseWidth < 14 and mouseHeight == 4) then
  179.         changeFarmStatus()
  180.     end
  181.     --Spawner Status --
  182.     if(mouseWidth > 27 and mouseWidth < 32 and mouseHeight == 4) then
  183.         changeSpawnerStatus()
  184.     end
  185.     -- 1st Row --
  186.     if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then
  187.         --Clicked Enderman --
  188.         currentMob = "Enderman"
  189.         setCurrentMobData()    
  190.         rednet.send(Turtle, 1) 
  191.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then
  192.         --Clicked Ghast--
  193.         currentMob = "Ghast"
  194.         setCurrentMobData()
  195.     rednet.send(Turtle, 6) 
  196.     -- 2nd Row --
  197.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then
  198.         --Clicked Skeleton --
  199.         currentMob = "Skeleton"
  200.         setCurrentMobData()
  201.         rednet.send(Turtle, 2)     
  202.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then
  203.         --Clicked Chicken --
  204.         currentMob = "Chicken"
  205.         setCurrentMobData()
  206.         rednet.send(Turtle, 7) 
  207.     -- 3rd Row --
  208.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then
  209.         --Clicked Blaze
  210.         currentMob = "Blaze"
  211.         setCurrentMobData()
  212.         rednet.send(Turtle, 3) 
  213.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then
  214.         --Clicked None --
  215.         currentMob = "Sheep"
  216.         setCurrentMobData()
  217.         rednet.send(Turtle, 8)     
  218.  
  219.     -- 4th Row --
  220.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 12) then
  221.         --Clicked Whisp --
  222.         currentMob = "Whisp"
  223.         setCurrentMobData()
  224.         rednet.send(Turtle, 4) 
  225.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 12) then
  226.         --Clicked None --
  227.         currentMob = "None"
  228.         setCurrentMobData()
  229.         rednet.send(Turtle, "Stop")
  230.  
  231.     -- 5th Row --
  232.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 14) then
  233.         --Clicked Cow --
  234.         currentMob = "Cow"
  235.         setCurrentMobData()
  236.         rednet.send(Turtle, 5)     
  237.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 14) then
  238.         --Clicked None --
  239.         currentMob = "None"
  240.         setCurrentMobData()
  241.         rednet.send(Turtle, "Stop")
  242.     end
  243. end
  244.  
  245. --First time data setup --
  246. setCurrentFarmStatusData()
  247. setCurrentSpawnerStatusData()
  248. setCurrentMobData()
  249.  
  250. repeat
  251.     event,p1,p2,p3 = os.pullEvent()
  252.  
  253.     if event == "monitor_touch" then
  254.         mouseWidth = p2
  255.         mouseHeight = p3
  256.         checkClickPosition()
  257.     end
  258. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment