Advertisement
ceribia

MobFarmer

Jun 30th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. function modemStartup()
  2. --print("Warping modem on " .. modemLocation .. " side")
  3. modem = peripheral.wrap("bottom")
  4. modem.open(3) -- Open channel 3 so that we can listen on it
  5. end
  6.  
  7. function clearRedstone()
  8. for key,side in pairs(redstone.getSides()) do
  9. redstone.setOutput(side, false)
  10. end
  11. end
  12.  
  13. function allButSide(side)
  14. for k,v in pairs(redstone.getSides()) do
  15. if side == v then
  16. redstone.setOutput(side, false)
  17. else
  18. redstone.setOutput(v, true)
  19. end
  20. end
  21. end
  22.  
  23. ------------------------------------------
  24. --Main Program
  25. ------------------------------------------
  26. print("Starting spawner control")
  27. modemStartup()
  28.  
  29. local mobs = {}
  30. mobs["endermen"] = "left"
  31. mobs["ghasts"] = "right"
  32. mobs["pigmen"] = "front"
  33. mobs["creepers"] = "back"
  34. mobs["all"] = "all"
  35. mobs["list"] = "list"
  36.  
  37. while true do
  38. local event, modemSide, senderChannel,
  39. replyChannel, message, senderDistance = os.pullEvent("modem_message")
  40.  
  41. print("Message: "..message)
  42.  
  43. local action = mobs[message]
  44. if action == "all" then
  45. clearRedstone()
  46. modem.transmit(replyChannel, 3, "spawning all mobs")
  47. elseif action == "list" then
  48. modem.transmit(replyChannel, 3, mobs)
  49. elseif action then
  50. allButSide(action)
  51. modem.transmit(replyChannel, 3, "spawning " .. message)
  52. else
  53. allButSide()
  54. modem.transmit(replyChannel, 3, "spawning no mobs")
  55. end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement