lua

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

mattyboy12

New Member
Jul 29, 2019
82
0
0
can anyone make or link me to a peice of code that will empty my turtles inventory from slot 2 to 14 and then pick the chest back up
 

Neirin

New Member
Jul 29, 2019
590
0
0
can anyone make or link me to a peice of code that will empty my turtles inventory from slot 2 to 14 and then pick the chest back up

Code:
if turtle.getItemCount(14) > 1
    turtle.select([slot you store chest in])
    turtle.place()
    for i = 2, 14 do
        turtle.select(i)
        turtle.drop()
    end
    turtle.select([slot you store chest in])
    turtle.dig()
end

EDIT: wait, that doesn't pick the chest back up, just a sec
EDIT2: ok, fixed
 
  • Like
Reactions: slay_mithos

solidity

Active Member
Jul 29, 2019
53
0
26
I'd change that code a bit, because if your turtle is in a situation where it can't put down the chest (block or mob in front of it), it would drop all the items on the floor.

Code:
if turtle.getItemCount(14) > 1 then
    turtle.select([slot you store chest in])
    local chestPlaced = turtle.place()
    while not chestPlaced do
        print("can't put down chest")
        if turtle.detect() then
            print("block in front, trying to dig it")
            turtle.dig()
        else
            print("no block in front, maybe a mob?")
            turtle.attack()
        end
        chestPlaced = turtle.place()
    end
    if chestPlaced then
        for i = 2, 14 do
            turtle.select(i)
            turtle.drop()
        end
        turtle.select([slot you store chest in])
        turtle.dig()
    else
        print("couldn't place chest")
    end
end
 
  • Like
Reactions: Neirin

Neirin

New Member
Jul 29, 2019
590
0
0
oh, gosh, I was just revisiting this thread and noticed a huge mistake I made. At the end of the very first line, there needs to be a "then." So it would look like if turtle.getItemCount(14) > 1 then

syntax errors are going to be the death of me.
 
  • Like
Reactions: solidity