Hiranus icon

Rainbow Tree Planter

Hiranus | PRO | 06/24/15 08:34:10 PM UTC | 0 ⭐ | 519 👁️ | Never ⏰ | []
Lua |

1.68 KB

|

None

|

0 👍

/

0 👎

function Find_In_Inventory (name,count,damage)
    for i=1,16 do
        turtle.select(i)
        slot = turtle.getItemDetail()
        if slot ~= nil then
            if slot["name"] == name then
                if count ~= nil then
                    if slot["count"] >=count then
                        if damage ~= nil then
                            if slot["damage"] == damage then
                                return i
                            end
                        else
                            return i
                        end
                    end
                else
                    if damage ~= nil then
                        if slot["damage"] == damage then
                            return i
                        end
                    else
                        return i
                    end
                end
            end
        end
    end
    return nil
end
function Refuel (value)
    while turtle.getFuelLevel()<=value do
        fuel_slot = Find_In_Inventory ("minecraft:coal",nil,nil)
        turtle.select(fuel_slot)
        turtle.refuel(1)
    end
end
function PlaceSquare()
    for i=1,4 do
    turtle.placeDown()
    turtle.forward()
    turtle.turnLeft()
    end
end
 
local rainbow_sapling 
local dirt 
 
while true do
local event = os.pullEvent()
    if event == "redstone" and redstone.getInput("right", true) then
            Refuel(50)
            rainbow_sapling =  Find_In_Inventory ("ChromatiCraft:chromaticraft_block_rainbowsapling",4,nil) 
            dirt =  Find_In_Inventory ("minecraft:dirt",4,nil) 
            if rainbow_sapling ~= nil and dirt ~= nil then
                while turtle.detect() do
                    sleep(1)
                end
                sleep(2)
                for fwd=1,3 do
                    turtle.forward()
                end
                turtle.select(dirt)
                PlaceSquare()
                turtle.up()
                turtle.select(rainbow_sapling)
                PlaceSquare()
                for i=1,2 do
                    turtle.turnLeft()
                end
                turtle.forward()
                turtle.down()
                for i=1,2 do
                    turtle.forward()
                end
                
                for i=1,2 do
                    turtle.turnLeft()
                end
            end
    end
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎