Tribble1991

Untitled

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