Advertisement
rhn

MFR autospawner touchscreen

rhn
May 31st, 2014
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 KB | None | 0 0
  1. mouseWidth = 0
  2. mouseHeight = 0
  3.  
  4. monitor = peripheral.wrap("top")
  5.  
  6. monitor.clear()
  7.  
  8.  
  9. monitor.setCursorPos(1,1)
  10.  
  11. w,h=monitor.getSize()
  12.  
  13. print(w)
  14. print(h)
  15.  
  16. -- Draw buttons
  17. monitor.setBackgroundColour((colours.lime))
  18. monitor.setCursorPos(2,2)
  19. monitor.write(" Wither Skelly  ")
  20.  
  21. monitor.setBackgroundColour((colours.lime))
  22. monitor.setCursorPos(2,4)
  23. monitor.write(" Blaze          ")
  24.  
  25. monitor.setBackgroundColour((colours.lime))
  26. monitor.setCursorPos(2,6)
  27. monitor.write(" Enderman       ")
  28.  
  29. monitor.setBackgroundColour((colours.lime))
  30. monitor.setCursorPos(2,8)
  31. monitor.write(" Ghast          ")
  32.  
  33. monitor.setBackgroundColour((colours.lime))
  34. monitor.setCursorPos(2,10)
  35. monitor.write(" Green Slime    ")
  36.  
  37. monitor.setBackgroundColour((colours.lime))
  38. monitor.setCursorPos(2,12)
  39. monitor.write(" Blizz          ")
  40.  
  41. monitor.setBackgroundColour((colours.lime))
  42. monitor.setCursorPos(2,14)
  43. monitor.write(" Mob 7          ")
  44.  
  45. monitor.setBackgroundColour((colours.lime))
  46. monitor.setCursorPos(2,16)
  47. monitor.write(" Villagers      ")
  48.  
  49. monitor.setBackgroundColour((colours.lime))
  50. monitor.setCursorPos(2,18)
  51. monitor.write("      STOP      ")
  52.  
  53. monitor.setBackgroundColour((colours.black))
  54.  
  55.  
  56.  
  57. -- Check click function
  58.  
  59. -- white: remove safari net
  60. -- orange: mob 1 Wither skeleton
  61. -- magenta: mob 2 Blaze
  62. -- lightBlue: mob 3 Enderman
  63. -- yellow: mob 4 Ghast
  64. -- lime: mob 5 Slime
  65. -- pink: mob 6 Blizz
  66. -- gray: mob 7
  67. -- lightgray: mob 8 Villagers
  68.  
  69. function checkClickPosition()
  70.   if mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 2 then
  71.     -- button 1 clicked
  72.         redstone.setBundledOutput("bottom", colors.white)
  73.     sleep(1)
  74.     redstone.setBundledOutput("bottom", colors.orange)
  75.   elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 4 then
  76.     -- button 2 clicked
  77.         redstone.setBundledOutput("bottom", colors.white)
  78.     sleep(1)
  79.     redstone.setBundledOutput("bottom", colors.magenta)
  80.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 6 then
  81.     -- button 3 clicked
  82.         redstone.setBundledOutput("bottom", colors.white)
  83.     sleep(1)
  84.     redstone.setBundledOutput("bottom", colors.lightBlue)
  85.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 8 then
  86.     -- button 4 clicked
  87.         redstone.setBundledOutput("bottom", colors.white)
  88.     sleep(1)
  89.     redstone.setBundledOutput("bottom", colors.yellow)
  90.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 10 then
  91.     -- button 5 clicked
  92.         redstone.setBundledOutput("bottom", colors.white)
  93.     sleep(1)
  94.     redstone.setBundledOutput("bottom", colors.lime)
  95.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 12 then
  96.     -- button 6 clicked
  97.         redstone.setBundledOutput("bottom", colors.white)
  98.     sleep(1)
  99.     redstone.setBundledOutput("bottom", colors.pink)
  100.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 14 then
  101.     -- button 7 clicked
  102.         redstone.setBundledOutput("bottom", colors.white)
  103.     sleep(1)
  104.     redstone.setBundledOutput("bottom", colors.gray)
  105.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 16 then
  106.     -- button 8 clicked (Villagers, auto stop after sleep period)
  107.         redstone.setBundledOutput("bottom", colors.white)
  108.     sleep(1)
  109.     redstone.setBundledOutput("bottom", colors.lightGray)
  110.     sleep(40)
  111.     redstone.setBundledOutput("bottom", colors.white)
  112.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 18 then
  113.     -- button 9 stop clicked
  114.         redstone.setBundledOutput("bottom", colors.white)
  115.   end
  116. end
  117.  
  118.  
  119.  
  120. repeat
  121.  
  122.  
  123.   event,p1,p2,p3 = os.pullEvent()
  124.  
  125.    if event=="monitor_touch" then
  126.    
  127.      mouseWidth = p2 -- sets mouseWidth
  128.      mouseHeight = p3 -- and mouseHeight
  129.      checkClickPosition() -- this runs our function
  130.      
  131.    end
  132.  
  133.    
  134.    
  135. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement