Tribble1991

Untitled

Jul 31st, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.00 KB | None | 0 0
  1. --Variables --
  2. mouseWidth = 0
  3. mouseHeight = 0
  4.  
  5. currentMob = "None"
  6. currentStatus = "On  "
  7.  
  8. --Set turtle connection --
  9. rednet.open("bottom")
  10. Turtle = 17
  11.  
  12.  
  13. --Set monitor properties
  14. monitor = peripheral.wrap("left")
  15. monitor.clear()
  16.  
  17. monitor.setCursorPos(1,1)
  18.  
  19. w,h=monitor.getSize()
  20.  
  21. --Write data --
  22. monitor.setBackgroundColor((colors.blue))
  23. monitor.setCursorPos(2,2)
  24. monitor.write("Spawner control ")
  25.  
  26. monitor.setBackgroundColor((colors.blue))
  27. monitor.setCursorPos(2,4)
  28. monitor.write("Status ")
  29.  
  30.  
  31. function setCurrentStatusData()
  32.     if currentStatus == "On  " then
  33.         monitor.setBackgroundColor((colors.green))
  34.     elseif currentStatus == "Off " then
  35.         monitor.setBackgroundColor((colors.red))
  36.     end
  37.     monitor.setCursorPos(10,4)
  38.     monitor.write(currentStatus)
  39. end
  40.  
  41. function setCurrentMobData()
  42.  
  43.     --Write first list of mobs
  44.    
  45.     monitor.setBackgroundColor((colors.red))
  46.    
  47.     if currentMob == "Enderman" then
  48.         monitor.setBackgroundColor((colors.green))
  49.     end
  50.     monitor.setCursorPos(2,6)
  51.     monitor.write("  Enderman  ")
  52.     monitor.setBackgroundColor((colors.red))
  53.  
  54.     if currentMob == "Skeleton" then
  55.         monitor.setBackgroundColor((colors.green))
  56.     end
  57.     monitor.setCursorPos(2,8)
  58.     monitor.write("  Skeleton  ")
  59.     monitor.setBackgroundColor((colors.red))
  60.  
  61.     if currentMob == "Blaze" then
  62.         monitor.setBackgroundColor((colors.green))
  63.     end
  64.     monitor.setCursorPos(2,10)
  65.     monitor.write("  Blaze     ")
  66.     monitor.setBackgroundColor((colors.red))
  67.  
  68.     if currentMob == "Whisp" then
  69.         monitor.setBackgroundColor((colors.green))
  70.     end
  71.     monitor.setCursorPos(2,12)
  72.     monitor.write("  Whisp     ")
  73.     monitor.setBackgroundColor((colors.red))
  74.  
  75.     if currentMob == "Cow" then
  76.         monitor.setBackgroundColor((colors.green))
  77.     end
  78.     monitor.setCursorPos(2,14)
  79.     monitor.write("  Cow       ")
  80.     monitor.setBackgroundColor((colors.red))
  81.  
  82.     --Write second list of mobs
  83.     if currentMob == "Ghast" then
  84.         monitor.setBackgroundColor((colors.green))
  85.     end
  86.     monitor.setCursorPos(16,6)
  87.     monitor.write("  Ghast     ")
  88.     monitor.setBackgroundColor((colors.red))
  89.    
  90.     if currentMob == "Chicken" then
  91.         monitor.setBackgroundColor((colors.green))
  92.     end
  93.     monitor.setCursorPos(16,8)
  94.     monitor.write("  Chicken   ")
  95.     monitor.setBackgroundColor((colors.red))
  96.  
  97.     monitor.setCursorPos(16,10)
  98.     monitor.write("  None      ")
  99.     monitor.setBackgroundColor((colors.red))
  100.  
  101.     monitor.setCursorPos(16,12)
  102.     monitor.write("  None      ")
  103.     monitor.setBackgroundColor((colors.red))
  104.  
  105.     if currentMob == "None" then
  106.         monitor.setBackgroundColor((colors.green))
  107.     end
  108.     monitor.setCursorPos(16,14)
  109.     monitor.write("  None      ")
  110.     monitor.setBackgroundColor((colors.red))
  111. end
  112.    
  113. -- Perform clicked action --
  114. function checkClickPosition()
  115.     --Status --
  116.     if(mouseWidth > 9 and mouseWidth < 14 and mouseHeight == 4) then
  117.         --Clicked Status --
  118.         if(currentStatus == "On  ") then
  119.             currentStatus = "Off "
  120.             rednet.send(Turtle, "Off") 
  121.         elseif(currentStatus == "Off ") then
  122.             currentStatus = "On  "
  123.             rednet.send(Turtle, "On")  
  124.         end
  125.         setCurrentStatusData()
  126.     end
  127.     -- 1st Row --
  128.     if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then
  129.         --Clicked Enderman --
  130.         currentMob = "Enderman"
  131.         setCurrentMobData()    
  132.         rednet.send(Turtle, 1) 
  133.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then
  134.         --Clicked Ghast--
  135.         currentMob = "Ghast"
  136.         setCurrentMobData()
  137.     rednet.send(Turtle, 6) 
  138.     -- 2nd Row --
  139.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then
  140.         --Clicked Skeleton --
  141.         currentMob = "Skeleton"
  142.         setCurrentMobData()
  143.         rednet.send(Turtle, 2)     
  144.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then
  145.         --Clicked Chicken --
  146.         currentMob = "Chicken"
  147.         setCurrentMobData()
  148.         rednet.send(Turtle, 7) 
  149.     -- 3rd Row --
  150.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then
  151.         --Clicked Blaze
  152.         currentMob = "Blaze"
  153.         setCurrentMobData()
  154.         rednet.send(Turtle, 3) 
  155.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then
  156.         --Clicked None --
  157.         currentMob = "None"
  158.         setCurrentMobData()
  159.         rednet.send(Turtle, "Stop")    
  160.  
  161.     -- 4th Row --
  162.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 12) then
  163.         --Clicked Whisp --
  164.         currentMob = "Whisp"
  165.         setCurrentMobData()
  166.         rednet.send(Turtle, 4) 
  167.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 12) then
  168.         --Clicked None --
  169.         currentMob = "None"
  170.         setCurrentMobData()
  171.         rednet.send(Turtle, "Stop")
  172.  
  173.     -- 5th Row --
  174.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 14) then
  175.         --Clicked Cow --
  176.         currentMob = "Cow"
  177.         setCurrentMobData()
  178.         rednet.send(Turtle, 5)     
  179.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 14) then
  180.         --Clicked None --
  181.         currentMob = "None"
  182.         setCurrentMobData()
  183.         rednet.send(Turtle, "Stop")
  184.     end
  185. end
  186.  
  187. --First time data setup --
  188. setCurrentMobData()
  189. setCurrentStatusData()
  190.  
  191. repeat
  192.     event,p1,p2,p3 = os.pullEvent()
  193.  
  194.     if event == "monitor_touch" then
  195.         mouseWidth = p2
  196.         mouseHeight = p3
  197.         checkClickPosition()
  198.     end
  199. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment