Tribble1991

Untitled

Jul 31st, 2014
200
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.     monitor.setBackgroundColor((colors.red))
  69.    
  70.     if currentMob == "Enderman" then
  71.         monitor.setBackgroundColor((colors.green))
  72.     end
  73.     monitor.setCursorPos(2,6)
  74.     monitor.write("  Enderman  ")
  75.     monitor.setBackgroundColor((colors.red))
  76.  
  77.     if currentMob == "Skeleton" then
  78.         monitor.setBackgroundColor((colors.green))
  79.     end
  80.     monitor.setCursorPos(2,8)
  81.     monitor.write("  Skeleton  ")
  82.     monitor.setBackgroundColor((colors.red))
  83.  
  84.     if currentMob == "Blaze" then
  85.         monitor.setBackgroundColor((colors.green))
  86.     end
  87.     monitor.setCursorPos(2,10)
  88.     monitor.write("  Blaze     ")
  89.     monitor.setBackgroundColor((colors.red))
  90.  
  91.     if currentMob == "Whisp" then
  92.         monitor.setBackgroundColor((colors.green))
  93.     end
  94.     monitor.setCursorPos(2,12)
  95.     monitor.write("  Whisp     ")
  96.     monitor.setBackgroundColor((colors.red))
  97.  
  98.     if currentMob == "Cow" then
  99.         monitor.setBackgroundColor((colors.green))
  100.     end
  101.     monitor.setCursorPos(2,14)
  102.     monitor.write("  Cow       ")
  103.     monitor.setBackgroundColor((colors.red))
  104.  
  105.     --Write second list of mobs
  106.     if currentMob == "Ghast" then
  107.         monitor.setBackgroundColor((colors.green))
  108.     end
  109.     monitor.setCursorPos(16,6)
  110.     monitor.write("  Ghast     ")
  111.     monitor.setBackgroundColor((colors.red))
  112.    
  113.     if currentMob == "Chicken" then
  114.         monitor.setBackgroundColor((colors.green))
  115.     end
  116.     monitor.setCursorPos(16,8)
  117.     monitor.write("  Chicken   ")
  118.     monitor.setBackgroundColor((colors.red))
  119.  
  120.     monitor.setCursorPos(16,10)
  121.     monitor.write("  None      ")
  122.     monitor.setBackgroundColor((colors.red))
  123.  
  124.     monitor.setCursorPos(16,12)
  125.     monitor.write("  None      ")
  126.     monitor.setBackgroundColor((colors.red))
  127.  
  128.     if currentMob == "None" then
  129.         monitor.setBackgroundColor((colors.green))
  130.     end
  131.     monitor.setCursorPos(16,14)
  132.     monitor.write("  None      ")
  133.     monitor.setBackgroundColor((colors.red))
  134. end
  135.  
  136. function changeFarmStatus()
  137.     --Clicked Status --
  138.     if(currentFarmStatus == "On  ") then
  139.         currentFarmStatus = "Off "
  140.         redstone.setOutput("right", false)
  141.     elseif(currentFarmStatus == "Off ") then
  142.         currentFarmStatus = "On  "
  143.         redstone.setOutput("right", true)
  144.     end
  145.     setCurrentFarmStatusData()
  146. end
  147.  
  148. function changeSpawnerStatus()
  149.     --Clicked Status --
  150.     if(currentSpawnerStatus == "On  ") then
  151.         currentSpawnerStatus = "Off "
  152.         rednet.send(Turtle, "Off") 
  153.     elseif(currentSpawnerStatus == "Off ") then
  154.         currentSpawnerStatus = "On  "
  155.         rednet.send(Turtle, "On")  
  156.     end
  157.     setCurrentSpawnerStatusData()
  158. end
  159.  
  160. -- Perform clicked action --
  161. function checkClickPosition()
  162.     --Farm Status --
  163.     if(mouseWidth > 9 and mouseWidth < 14 and mouseHeight == 4) then
  164.         changeFarmStatus()
  165.     end
  166.     --Spawner Status --
  167.     if(mouseWidth > 27 and mouseWidth < 32 and mouseHeight == 4) then
  168.         changeSpawnerStatus()
  169.     end
  170.     -- 1st Row --
  171.     if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then
  172.         --Clicked Enderman --
  173.         currentMob = "Enderman"
  174.         setCurrentMobData()    
  175.         rednet.send(Turtle, 1) 
  176.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then
  177.         --Clicked Ghast--
  178.         currentMob = "Ghast"
  179.         setCurrentMobData()
  180.     rednet.send(Turtle, 6) 
  181.     -- 2nd Row --
  182.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then
  183.         --Clicked Skeleton --
  184.         currentMob = "Skeleton"
  185.         setCurrentMobData()
  186.         rednet.send(Turtle, 2)     
  187.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then
  188.         --Clicked Chicken --
  189.         currentMob = "Chicken"
  190.         setCurrentMobData()
  191.         rednet.send(Turtle, 7) 
  192.     -- 3rd Row --
  193.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then
  194.         --Clicked Blaze
  195.         currentMob = "Blaze"
  196.         setCurrentMobData()
  197.         rednet.send(Turtle, 3) 
  198.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then
  199.         --Clicked None --
  200.         currentMob = "None"
  201.         setCurrentMobData()
  202.         rednet.send(Turtle, "Stop")    
  203.  
  204.     -- 4th Row --
  205.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 12) then
  206.         --Clicked Whisp --
  207.         currentMob = "Whisp"
  208.         setCurrentMobData()
  209.         rednet.send(Turtle, 4) 
  210.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 12) then
  211.         --Clicked None --
  212.         currentMob = "None"
  213.         setCurrentMobData()
  214.         rednet.send(Turtle, "Stop")
  215.  
  216.     -- 5th Row --
  217.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 14) then
  218.         --Clicked Cow --
  219.         currentMob = "Cow"
  220.         setCurrentMobData()
  221.         rednet.send(Turtle, 5)     
  222.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 14) then
  223.         --Clicked None --
  224.         currentMob = "None"
  225.         setCurrentMobData()
  226.         rednet.send(Turtle, "Stop")
  227.     end
  228. end
  229.  
  230. --First time data setup --
  231. setCurrentFarmStatusData()
  232. setCurrentSpawnerStatusData()
  233. setCurrentMobData()
  234.  
  235. repeat
  236.     event,p1,p2,p3 = os.pullEvent()
  237.  
  238.     if event == "monitor_touch" then
  239.         mouseWidth = p2
  240.         mouseHeight = p3
  241.         checkClickPosition()
  242.     end
  243. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment