Tribble1991

Untitled

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