Tribble1991

Untitled

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