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