Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stone_slot = 0
- local stone_slots = 0
- local ender_chest_slot = 1
- local forward_motion = 0
- local down_motion = 0
- term.write("Insert Length: ")
- Length = tonumber(read()) - 1
- print(" ")
- term.write("Insert Height: ")
- Height = tonumber(read())
- print(" ")
- local Length = Length
- local Height = Height
- --do i need to place a block, or not...
- function place_or_not()
- turtle.turnLeft()
- local succes, t = turtle.inspect()
- if succes then
- if string.find(t.name, "cobble") then
- else
- selectStone()
- while turtle.place() == false do
- turtle.dig()
- end
- end
- end
- turtle.turnRight()
- end
- --select stone or glass, if not found (more than one) than refill
- function selectStone()
- local is_stone = 0
- for q=2,15 do
- local item_detail = turtle.getItemDetail(q)
- if item_detail then
- if string.find(item_detail.name, "cobble") ~= nil and item_detail.count > 1 then
- is_stone = q
- break
- end
- end
- end
- if is_stone == 0 then
- print("no stones found, gotte get some")
- refilChest()
- else
- stone_slot = is_stone
- turtle.select(stone_slot)
- print(stone_slot)
- end
- end
- --get bricks or glass from enderchest
- function refilChest()
- turtle.select(ender_chest_slot)
- if turtle.place() then
- --suck all items, than turn left
- for q=2,16 do
- turtle.select(q)
- local toSuck = 64 - turtle.getItemCount(q)
- turtle.suck(toSuck)
- end
- --
- turtle.select(ender_chest_slot)
- if turtle.getItemCount(ender_chest_slot) == 0 then
- print("Chest is right")
- turtle.dig()
- turtle.select(2)
- else
- turtle.select(ender_chest_slot)
- turtle.drop(64)
- turtle.dig()
- turtle.select(2)
- end
- else
- --als ik 'm niet kan plaatsten moet hij draaien ofzo
- turtle.turnRight()
- if turtle.place() then
- --suck all items, than turn Right
- for q=2,16 do
- turtle.select(q)
- local toSuck = 64 - turtle.getItemCount(q)
- turtle.suck(toSuck)
- end
- --
- turtle.select(ender_chest_slot)
- if turtle.getItemCount(ender_chest_slot) == 0 then
- print("Chest is right")
- turtle.dig()
- turtle.select(2)
- else
- turtle.select(ender_chest_slot)
- turtle.drop(64)
- turtle.dig()
- turtle.select(2)
- end
- turtle.turnLeft()
- else
- while turtle.place() == false do
- turtle.dig()
- end
- --suck all items, than turn Right
- for q=2,16 do
- turtle.select(q)
- local toSuck = 64 - turtle.getItemCount(q)
- turtle.suck(toSuck)
- end
- turtle.select(ender_chest_slot)
- if turtle.getItemCount(ender_chest_slot) == 0 then
- print("Chest is right")
- turtle.dig()
- turtle.select(2)
- else
- turtle.select(ender_chest_slot)
- turtle.drop(64)
- turtle.dig()
- turtle.select(2)
- end
- turtle.turnLeft()
- end
- end
- end
- --check if everything is still correct..
- function empty_if_not_right()
- if string.find(turtle.getItemDetail(1).name, "ender") ~= nil then
- print("Chest is right")
- else
- print("Seem to lost my chest? ")
- end
- for p=2,16 do
- if string.find(turtle.getItemDetail(p).name, "cobble") ~= nil then
- print("Slot: " .. p .. " has stones")
- else
- turtle.select(p)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.drop(64)
- turtle.turnRight()
- turtle.turnRight()
- print("Seem to have no stone? ")
- refilChest()
- end
- end
- end
- function makeLine()
- place_or_not()
- repeat
- while turtle.forward() == false do
- turtle.dig()
- end
- forward_motion = forward_motion + 1
- place_or_not()
- until forward_motion == Length
- repeat
- if turtle.back() then
- forward_motion = forward_motion - 1
- end
- until forward_motion == 0
- end
- function start()
- print("Starting")
- repeat
- makeLine()
- empty_if_not_right()
- if turtle.down() then
- down_motion = down_motion + 1
- end
- until down_motion == Height
- makeLine()
- repeat
- if turtle.up() then
- down_motion = down_motion - 1
- end
- until down_motion == 0
- print("Done?")
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement