Aixler

slaveSpawner

Nov 8th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. function drop()
  2.     for x=1, 16 do
  3.         if turtle.getItemCount(x) > 0 then
  4.             turtle.select(x)
  5.             turtle.drop()
  6.         end
  7.     end
  8.     turtle.select(1)
  9. end
  10.  
  11. drop()
  12.  
  13. chestSide = "left"
  14. spawnerSide = "top"
  15. modemSide = "right"
  16. monitorID = 112
  17.  
  18. m = peripheral.wrap(modemSide)
  19. rednet.open(modemSide)
  20.  
  21. tArgs = { ... }
  22.  
  23. if #tArgs == 1 then
  24.     if tArgs[1] == "On" then
  25.         rs.setOutput("top", true)
  26.     elseif tArgs[1] == "Off" then
  27.         rs.setOutput("top", false)
  28.     end
  29. end
  30.  
  31. function main()
  32.     id, msg, distance = nil, nil, nil
  33.     id, msg, distance = rednet.receive()
  34.     if id == monitorID then
  35.         if msg == "Empty" then
  36.             turtle.suckUp()
  37.             drop()
  38.             rednet.send(monitorID, "Empty done")
  39.         elseif msg == "Full" then
  40.             turtle.suck()
  41.             turtle.dropUp()
  42.             rednet.send(monitorID, "Full done")
  43.         elseif msg == "On" then
  44.             rs.setOutput("top", false)
  45.             redstone = "On"
  46.             save()
  47.             rednet.send(monitorID, "On done")      
  48.         elseif msg == "Off" then
  49.             rs.setOutput("top", true)
  50.             redstone = "Off"
  51.             save()
  52.             rednet.send(monitorID, "Off done")
  53.         end
  54.     end
  55. end
  56.  
  57. function save()             --saving position
  58.     file = fs.open("startup", "w")      --open startup in writemode
  59.     file.write('shell.run("slave", \''..redstone..'\')')
  60.     file.close()
  61. end
  62.  
  63. while true do
  64.     main()
  65.     sleep(1)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment