Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 0
- z = 0
- totalBlocks = 0
- facing = "north"
- slot = 1
- xmem = 0
- ymem = 0
- zmem = 0
- facingmem = "north"
- print("Length = ?")
- l = tonumber(read())
- print("Width = ?")
- w = tonumber(read())
- print("Height = ?")
- h = tonumber(read())
- function turn(direction)
- if direction == "north" then
- if facing == "west" then
- turtle.turnRight()
- end
- if facing == "south" then
- turtle.turnRight()
- turtle.turnRight()
- end
- if facing == "east" then
- turtle.turnLeft()
- end
- facing = "north"
- end
- if direction == "west" then
- if facing == "south" then
- turtle.turnRight()
- end
- if facing == "east" then
- turtle.turnRight()
- turtle.turnRight()
- end
- if facing == "north" then
- turtle.turnLeft()
- end
- facing = "west"
- end
- if direction == "south" then
- if facing == "east" then
- turtle.turnRight()
- end
- if facing == "north" then
- turtle.turnRight()
- turtle.turnRight()
- end
- if facing == "west" then
- turtle.turnLeft()
- end
- facing = "south"
- end
- if direction == "east" then
- if facing == "north" then
- turtle.turnRight()
- end
- if facing == "west" then
- turtle.turnRight()
- turtle.turnRight()
- end
- if facing == "south" then
- turtle.turnLeft()
- end
- facing = "east"
- end
- end
- function returnHome()
- xmem = x
- ymem = y
- zmem = z
- facingmem = facing
- while z < h + 1 do
- if turtle.up() then
- z = z + 1
- end
- end
- turn("west")
- while x > 0 do
- if turtle.forward() then
- x = x - 1
- end
- end
- turn("south")
- while y > -1 do
- if turtle.forward() then
- y = y - 1
- end
- end
- turn("north")
- while z > 0 do
- if turtle.down() then
- z = z - 1
- end
- end
- end
- function resume()
- while z < h + 1 do
- if turtle.up() then
- z = z + 1
- end
- end
- while y < ymem do
- if turtle.forward() then
- y = y + 1
- end
- end
- turn("east")
- while x < xmem do
- if turtle.forward() then
- x = x + 1
- end
- end
- turn(facingmem)
- while z > zmem do
- if turtle.down() then
- z = z - 1
- end
- end
- end
- function refill()
- returnHome()
- for i = 1,16,1 do
- turtle.suckDown()
- end
- resume()
- end
- function countBlocks()
- totalBlocks = 0
- for i = 1,16,1 do
- totalBlocks = totalBlocks + turtle.getItemCount(i)
- end
- end
- function checkForRefill()
- countBlocks()
- if totalBlocks < h then
- refill()
- end
- end
- function selectSlot()
- if turtle.getItemCount(slot) == 0 and slot < 16 then
- slot = slot + 1
- elseif turtle.getItemCount(slot) == 0 and slot == 16 then
- slot = 1
- end
- turtle.select(slot)
- end
- function pillar()
- checkForRefill()
- while z < h do
- if turtle.up() then
- z = z + 1
- end
- selectSlot()
- turtle.placeDown()
- end
- if x == 0 and y == 0 then
- turn("north")
- end
- if x == 0 and y == l - 1 then
- turn("east")
- end
- if x == w - 1 and y == 0 then
- turn("west")
- end
- if x == w - 1 and y == l - 1 then
- turn("south")
- end
- if turtle.forward() then
- if facing == "north" then
- y = y + 1
- end
- if facing == "west" then
- x = x - 1
- end
- if facing == "south" then
- y = y - 1
- end
- if facing == "east" then
- x = x + 1
- end
- end
- while z > 0 do
- if turtle.down() then
- z = z - 1
- end
- end
- end
- while true do
- pillar()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement