Advertisement
Tribble1991

Untitled

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