Advertisement
rhn

MFR autospawner touchscreen CC1.63+

rhn
Dec 6th, 2014
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MFR Autospawner control panel using AE, for CC 1.63+ (No Bundled cable support).
  2. -- Outputs Redstone signal in varying strength down bottom of computer. Use a MFR Programmable Rednet Controller to translate RS strength signals into Bundled cable colour channels corresponding to table below:
  3. -- white/RSS 1: remove safari net
  4. -- orange/RSS 2: mob 1 Wither skeleton
  5. -- magenta/RSS 3: mob 2 Blaze
  6. -- lightBlue/RSS 4: mob 3 Enderman
  7. -- yellow/RSS 5: mob 4 Ghast
  8. -- lime/RSS 6: mob 5 Slime
  9. -- pink/RSS 7: mob 6 Blizz
  10. -- gray/RSS 8: mob 7
  11. -- lightgray/RSS 9: mob 8 Villagers
  12.  
  13. --Details on "physical" build: http://forum.feed-the-beast.com/threads/rhns-continued-adventures-a-build-journal-guide-collection-etc.42664/page-10#post-658213
  14.  
  15.  
  16. mouseWidth = 0
  17. mouseHeight = 0
  18.  
  19. function detectDevice(DeviceName)
  20. DeviceSide="none"
  21. for k,v in pairs(redstone.getSides()) do
  22.  if peripheral.getType(v)==DeviceName then
  23.    DeviceSide = v
  24.    break
  25.  end
  26. end
  27.   return(DeviceSide)
  28. end
  29.  
  30. MonitorSide=detectDevice("monitor")
  31.  
  32. if MonitorSide~="none" then
  33.       monitor=peripheral.wrap(MonitorSide)
  34.    print ("Monitor on the " .. MonitorSide .. " connected.")
  35. else
  36.    print("No monitor found")
  37. end
  38.  
  39. monitor.clear()
  40.  
  41.  
  42. monitor.setCursorPos(1,1)
  43.  
  44. w,h=monitor.getSize()
  45.  
  46. print(w)
  47. print(h)
  48.  
  49. -- Draw buttons
  50. monitor.setBackgroundColour((colours.lime))
  51. monitor.setCursorPos(2,2)
  52. monitor.write(" Wither Skelly  ")
  53.  
  54. monitor.setBackgroundColour((colours.lime))
  55. monitor.setCursorPos(2,4)
  56. monitor.write(" Blaze          ")
  57.  
  58. monitor.setBackgroundColour((colours.lime))
  59. monitor.setCursorPos(2,6)
  60. monitor.write(" Enderman       ")
  61.  
  62. monitor.setBackgroundColour((colours.lime))
  63. monitor.setCursorPos(2,8)
  64. monitor.write(" Ghast          ")
  65.  
  66. monitor.setBackgroundColour((colours.lime))
  67. monitor.setCursorPos(2,10)
  68. monitor.write(" Green Slime    ")
  69.  
  70. monitor.setBackgroundColour((colours.lime))
  71. monitor.setCursorPos(2,12)
  72. monitor.write(" Blizz          ")
  73.  
  74. monitor.setBackgroundColour((colours.lime))
  75. monitor.setCursorPos(2,14)
  76. monitor.write(" Mob 7          ")
  77.  
  78. monitor.setBackgroundColour((colours.lime))
  79. monitor.setCursorPos(2,16)
  80. monitor.write(" Villagers      ")
  81.  
  82. monitor.setBackgroundColour((colours.lime))
  83. monitor.setCursorPos(2,18)
  84. monitor.write("      STOP      ")
  85.  
  86. monitor.setBackgroundColour((colours.black))
  87.  
  88.  
  89.  
  90. -- Check click function
  91.  
  92.  
  93. -- white/RSS 1: remove safari net
  94. -- orange/RSS 2: mob 1 Wither skeleton
  95. -- magenta/RSS 3: mob 2 Blaze
  96. -- lightBlue/RSS 4: mob 3 Enderman
  97. -- yellow/RSS 5: mob 4 Ghast
  98. -- lime/RSS 6: mob 5 Slime
  99. -- pink/RSS 7: mob 6 Blizz
  100. -- gray/RSS 8: mob 7
  101. -- lightgray/RSS 9: mob 8 Villagers
  102.  
  103.  
  104. function checkClickPosition()
  105.   if mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 2 then
  106.     -- button 1 clicked
  107.         redstone.setAnalogOutput("bottom", 1)
  108.     sleep(1)
  109.     redstone.setAnalogOutput("bottom", 2)
  110.   elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 4 then
  111.     -- button 2 clicked
  112.         redstone.setAnalogOutput("bottom", 1)
  113.     sleep(1)
  114.     redstone.setAnalogOutput("bottom", 3)
  115.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 6 then
  116.     -- button 3 clicked
  117.         redstone.setAnalogOutput("bottom", 1)
  118.     sleep(1)
  119.     redstone.setAnalogOutput("bottom", 4)
  120.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 8 then
  121.     -- button 4 clicked
  122.         redstone.setAnalogOutput("bottom", 1)
  123.     sleep(1)
  124.     redstone.setAnalogOutput("bottom", 5)
  125.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 10 then
  126.     -- button 5 clicked
  127.         redstone.setAnalogOutput("bottom", 1)
  128.     sleep(1)
  129.     redstone.setAnalogOutput("bottom", 6)
  130.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 12 then
  131.     -- button 6 clicked
  132.         redstone.setAnalogOutput("bottom", 1)
  133.     sleep(1)
  134.     redstone.setAnalogOutput("bottom", 7)
  135.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 14 then
  136.     -- button 7 clicked
  137.         redstone.setAnalogOutput("bottom", 1)
  138.     sleep(1)
  139.     redstone.setAnalogOutput("bottom", 8)
  140.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 16 then
  141.     -- button 8 clicked (Villagers, auto stop after sleep period)
  142.         redstone.setAnalogOutput("bottom", 1)
  143.     sleep(1)
  144.     redstone.setAnalogOutput("bottom", 9)
  145.     sleep(40)
  146.     redstone.setAnalogOutput("bottom", 1)
  147.    elseif mouseWidth > 1 and mouseWidth < 18 and mouseHeight == 18 then
  148.     -- button 9 stop clicked
  149.         redstone.setAnalogOutput("bottom", 1)
  150.   end
  151. end
  152.  
  153.  
  154.  
  155. repeat
  156.  
  157.  
  158.   event,p1,p2,p3 = os.pullEvent()
  159.  
  160.    if event=="monitor_touch" then
  161.    
  162.      mouseWidth = p2 -- sets mouseWidth
  163.      mouseHeight = p3 -- and mouseHeight
  164.      checkClickPosition() -- this runs our function
  165.      
  166.    end
  167.  
  168.    
  169.    
  170. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement