Jayex_Designs

deployer

Jun 21st, 2021 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. args = {...}
  2. if not args[1] then
  3.     error("Set the id of the server")
  4. end
  5.  
  6. ServerId = tonumber(args[1])
  7. SLOT_COUNT = 16
  8.  
  9. rednet.open("left")
  10.  
  11.  
  12.  
  13. function GetItemIndex(itemName)
  14.     for slot = 1, SLOT_COUNT, 1 do
  15.         local item = turtle.getItemDetail(slot)
  16.         if(item ~= nil) then
  17.             if(item["name"] == itemName) then
  18.                 return slot
  19.             end
  20.         end
  21.     end
  22. end
  23.  
  24.  
  25.  
  26. rednet.send(ServerId, "", "deployerPing")
  27.  
  28. while true do
  29.     local id, message, protocol = rednet.receive()
  30.     if protocol == "deploy" then
  31.         local slot = GetItemIndex("computercraft:turtle_normal")
  32.         turtle.select(slot)
  33.         turtle.place()
  34.         slot = GetItemIndex("minecraft:coal")
  35.         turtle.select(slot)
  36.         turtle.drop()
  37.         local drone = peripheral.wrap("front")
  38.         drone.turnOn()
  39.         sleep(1)
  40.         local droneId = drone.getID()
  41.         sleep(1)
  42.         rednet.send(droneId, message, "droneStart")
  43.  
  44.     elseif protocol == "droneEnd" then
  45.         turtle.dig()
  46.     end
  47. end
Add Comment
Please, Sign In to add comment