HANDZ

Draconic crafting automation (2 turtles - second turtle)

Aug 24th, 2021 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. --[[
  2. down - injector
  3. --]]
  4.  
  5. local turtle_id = 13
  6.  
  7. -----------------
  8.  
  9. rednet.open("left")
  10.  
  11. while true do
  12.     local id, msg = rednet.receive()
  13.  
  14.     if id == turtle_id then
  15.         local error = ""
  16.  
  17.         if msg == "RETRIEVE" then
  18.             print("Processed command to retrieve item")
  19.             turtle.suckDown()
  20.         else
  21.             for i=1,16 do
  22.                 local slot = turtle.getItemDetail(i)
  23.                 if slot and slot.name == msg.name and slot.damage == msg.damage then
  24.                     print("Processed command to send item: " .. msg.name .. "/" .. msg.damage)
  25.                     turtle.select(i)
  26.                     turtle.dropDown()
  27.                     break
  28.                 elseif i == 16 then
  29.                     print("Item not found: " .. msg.name .. "/" .. msg.damage)
  30.                     error = msg.name .. "/" .. msg.damage .. " not found"
  31.                 end
  32.             end
  33.         end
  34.  
  35.         if error ~= "" then
  36.             rednet.send(id, error)
  37.         else
  38.             rednet.send(id, "DONE")
  39.         end
  40.     end
  41. end
Add Comment
Please, Sign In to add comment