Tribble1991

Untitled

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