Tribble1991

Untitled

Jul 26th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Checking the file system --
  2.  
  3. if not fs.exists("OnlineStatus") then
  4.   StatusWriter = fs.open("OnlineStatus", "w")
  5.   StatusWriter .write("On")
  6.   StatusWriter .close()
  7. end
  8.  
  9. if not fs.exists("CurrentMob") then
  10.   MobWriter= fs.open("CurrentMob", "w")
  11.   MobWriter.write("None")
  12.   MobWriter.close()
  13. end
  14.  
  15.  
  16. --Variables --
  17. mouseWidth = 0
  18. mouseHeight = 0
  19.  
  20. currentMob = "None        "
  21.  
  22.  
  23. --Set turtle connection --
  24. rednet.open("back")
  25. Turtle = 35
  26.  
  27.  
  28. --Set monitor properties
  29. monitor = peripheral.wrap("bottom")
  30. monitor.clear()
  31.  
  32. monitor.setCursorPos(1,1)
  33.  
  34. w,h=monitor.getSize()
  35.  
  36. monitor.setBackgroundColor((colors.blue))
  37.  
  38. --Write first list of mobs
  39. monitor.setCursorPos(2,2)
  40. monitor.write("  Enderman  ")
  41.  
  42. monitor.setCursorPos(2,4)
  43. monitor.write("  Skeleton  ")
  44.  
  45. monitor.setCursorPos(2,6)
  46. monitor.write("  Blaze     ")
  47.  
  48. monitor.setCursorPos(2,8)
  49. monitor.write("  Whisp     ")
  50.  
  51. monitor.setCursorPos(2,10)
  52. monitor.write("  Cow       ")
  53.  
  54. --Write second list of mobs
  55. monitor.setCursorPos(16,2)
  56. monitor.write("  Enderman  ")
  57.  
  58. monitor.setCursorPos(16,4)
  59. monitor.write("  Skeleton  ")
  60.  
  61. monitor.setCursorPos(16,6)
  62. monitor.write("  Blaze     ")
  63.  
  64. monitor.setCursorPos(16,8)
  65. monitor.write("  Whisp     ")
  66.  
  67. monitor.setCursorPos(16,10)
  68. monitor.write("  None      ")
  69.  
  70. --Write data --
  71. monitor.setBackgroundColor((colors.red))
  72. monitor.setCursorPos(2,12)
  73. monitor.write("Current Mob: ")
  74.  
  75.    
  76.  
  77. --Update mob data --
  78. function setCurrentMobData()
  79.     monitor.setBackgroundColor((colors.red))
  80.     monitor.setCursorPos(15,12)
  81.     monitor.write(currentMob)
  82. end
  83.  
  84. --Switch mob --
  85. function switchMob(mob)
  86.     print "Switching mob"
  87. end
  88.  
  89. --Remove mob --
  90. function removeMob()
  91.     print "Removing mob"
  92. end
  93. -- Perform clicked action --
  94. function checkClickPosition()
  95.     -- 1st Row --
  96.     if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 2) then
  97.         --Clicked Enderman --
  98.         currentMob = "Enderman "
  99.         setCurrentMobData()
  100.         rednet.send(Turtle, 1) 
  101.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 2) then
  102.         --Clicked enderman --
  103.         currentMob = "Enderman "
  104.         setCurrentMobData()
  105.     -- 2nd Row --
  106.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 4) then
  107.         --Clicked Skeleton --
  108.         currentMob = "Skeleton "
  109.         setCurrentMobData()
  110.         rednet.send(Turtle, 2)     
  111.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 4) then
  112.         --Clicked Skeleton --
  113.         currentMob = "Skeleton "
  114.         setCurrentMobData()
  115.     -- 3rd Row --
  116.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then
  117.         --Clicked Blaze
  118.         currentMob = "Blaze    "
  119.         setCurrentMobData()
  120.         rednet.send(Turtle, 3) 
  121.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then
  122.         --Clicked Blaze --
  123.         currentMob = "Blaze    "
  124.         setCurrentMobData()
  125.  
  126.     -- 4th Row --
  127.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then
  128.         --Clicked Whisp --
  129.         currentMob = "Whisp    "
  130.         setCurrentMobData()
  131.         rednet.send(Turtle, 4) 
  132.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then
  133.         --Clicked Whisp --
  134.         currentMob = "Whisp    "
  135.         setCurrentMobData()
  136.  
  137.     -- 5th Row --
  138.     elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then
  139.         --Clicked Cow --
  140.         currentMob = "Cow      "
  141.         setCurrentMobData()
  142.         rednet.send(Turtle, 5)     
  143.     elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then
  144.         --Clicked Whisp --
  145.         currentMob = "None     "
  146.         setCurrentMobData()
  147.         rednet.send(Turtle, "Stop")
  148.     end
  149. end
  150.  
  151. repeat
  152.     event,p1,p2,p3 = os.pullEvent()
  153.  
  154.     if event == "monitor_touch" then
  155.         mouseWidth = p2
  156.         mouseHeight = p3
  157.         checkClickPosition()
  158.     end
  159. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment