Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stone_slot = 0
- local ender_chest_slot = 1
- local forward_motion = 0
- local left_motion = 0
- local left_right = "right"
- term.write("Insert Length: ")
- Length = tonumber(read()) - 1
- print(" ")
- term.write("Insert Width: ")
- Width = tonumber(read())
- print(" ")
- local Length = Length
- local Width = Width
- 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, "stone_slab") ~= 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
- 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
- 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, "stone_slab") ~= 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 place_or_not()
- selectStone()
- while turtle.placeUp() == false do
- turtle.digUp()
- end
- end
- function makeLine()
- place_or_not()
- repeat
- if turtle.forward() then
- forward_motion = forward_motion + 1
- place_or_not()
- else
- if forward_motion > (Length - 10) then
- break
- end
- end
- until forward_motion == Length
- forward_motion = 0
- end
- function start()
- print("Starting")
- repeat
- makeLine()
- empty_if_not_right()
- if left_right == "left" then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- left_motion = left_motion + 1
- left_right = "right"
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- left_motion = left_motion + 1
- left_right = "left"
- end
- until left_motion == Width
- makeLine()
- print("Done?")
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement