Advertisement
Guest User

spawnerTurtle

a guest
Aug 1st, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. local computerID = 1
  2.  
  3. local mobs = {}
  4. local chest = peripheral.wrap("bottom")
  5.  
  6. rednet.open("right")
  7.  
  8. function loadMobs()
  9.     turtle.suckUp()
  10.     turtle.dropDown()
  11.     for i,p in pairs(chest.getAllStacks()) do
  12.         mobs[p["name"]] = i
  13.     end
  14. end
  15.  
  16. function printMobs()
  17.     for i,p in pairs(mobs) do
  18.         print("Mob "..i.." is in Slot "..p)
  19.     end
  20. end
  21.  
  22. function waitRednet()
  23.     senderID, msg = rednet.receive()
  24.     if senderID == computerID then
  25.        if msg == "getMobs" then
  26.            rednet.send(senderID, textutils.serialize(mobs))
  27.        elseif msg == "on" then
  28.            rs.setOutput("top", false)
  29.        elseif msg == "off" then
  30.             rs.setOutput("top", true)
  31.        else
  32.             insertMob(msg)
  33.        end
  34.     end
  35. end
  36.  
  37. function insertMob(mobName)
  38.     turtle.suckUp()
  39.     turtle.dropDown()
  40.     chest.pushItem("up", mobs[mobName], 1)
  41.     turtle.dropUp()
  42. end
  43.  
  44. loadMobs()
  45. printMobs()
  46. while true do waitRednet() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement