jille_Jr icon

CC: Crafting script [ERRORS]

jille_Jr | PRO | 09/27/12 06:41:47 PM UTC | 0 ⭐ | 470 👁️ | Never ⏰ | []
Lua |

1.02 KB

|

None

|

0 👍

/

0 👎

while not turtle.detectDown() do
  turtle.down() -- get the turtle down to the ground.
end
turtle.up() -- to keep the turtle 1 block up in the air.
 
-- I got 2 pieces of log, and I want to craft a chest...
-- The log is in the first position in the turtles inventory
turtle.select(1)
turtle.craft(2)
 
for i = 1, 9 do -- I THINK this will execute 8 times, starting on 1...
  if i == 4 or i == 6 or i == 8 then i = i + 1 end -- to get the crafting grid for a chest.
  if i ~= 8 then turtle.dropDown(8 - i) end -- drop the stuff below the turtle, unless it's on it's 8th run.
  if i ~= 1 then turtle.select(i) end -- select the correct slot (not on first run)
  if i ~= 8 then turtle.suckDown() end -- pick everything thats below up again, putting it in the expected slot.
end
 
if not turtle.craft() then
  print("Failed crafting!")
end
 
-- so the turtle should place wooden planks in this pattern:
-- [ ] [ ] [ ]
-- [ ] N/A [ ]
-- [ ] [ ] [ ]
-- unless someone else picks up the blocks or if extra blocks where placed below

Comments