Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local length = 3
- local width = 4
- local height = 3
- local bigness = 1
- local g_length = length + 2 * bigness
- local g_width = width + 2 * bigness
- local g_height = height + 2 * bigness
- local nl = 1
- local nw = 1
- local nh = 1
- local l_pos = 1
- local w_pos = 1
- local h_pos = 1
- function turtleF()
- while turtle.detect() == true do
- turtle.dig()
- sleep(1)
- end
- turtle.forward()
- end
- function turtleD()
- while turtle.detectDown() == true do
- turtle.digDown()
- sleep(1)
- end
- turtle.down()
- end
- function go_length (l, pos)
- local i = 1
- if nl % 2 == 1 then
- while i<l do
- turtleF()
- pos = pos + 1
- i = i + 1
- end
- else
- while i<l do
- turtleF()
- pos = pos - 1
- i = i + 1
- end
- end
- nl = nl + 1
- return pos
- end
- function go_width (l, w, h, posl, posw)
- local i = 0
- if h % 2 == 1 then
- if nw % 2 == 1 then
- while i < w do
- posl = go_length(l, posl)
- if posl == l and i < w - 1 then
- turtle.turnLeft()
- turtleF()
- turtle.turnLeft()
- posw = posw + 1
- elseif posl == 1 and i < w - 1 then
- turtle.turnRight()
- turtleF()
- turtle.turnRight()
- posw = posw + 1
- end
- i = i + 1
- end
- else
- while i < w do
- posl = go_length(l, posl)
- if posl == l and i < w - 1 then
- turtle.turnLeft()
- turtleF()
- turtle.turnLeft()
- posw = posw - 1
- elseif posl == 1 and i < w - 1 then
- turtle.turnRight()
- turtleF()
- turtle.turnRight()
- posw = posw - 1
- end
- i = i + 1
- end
- end
- else
- if nw % 2 == 1 then
- while i < w do
- posl = go_length(l, posl)
- if posl == l and i < w - 1 then
- turtle.turnRight()
- turtleF()
- turtle.turnRight()
- posw = posw + 1
- elseif posl == 1 and i < w - 1 then
- turtle.turnLeft()
- turtleF()
- turtle.turnLeft()
- posw = posw + 1
- end
- i = i + 1
- end
- else
- while i < w do
- posl = go_length(l, posl)
- if posl == l and i < w - 1 then
- turtle.turnRight()
- turtleF()
- turtle.turnRight()
- posw = posw - 1
- elseif posl == 1 and i < w - 1 then
- turtle.turnLeft()
- turtleF()
- turtle.turnLeft()
- posw = posw - 1
- end
- i = i + 1
- end
- end
- end
- nw = nw + 1
- local a = {posl, posw}
- return a
- end
- function go_height (l, w, h, posl, posw, posh)
- local i = 1
- while i < h do
- local pa = go_width (l, w, i, posl, posw)
- posl = pa[1]
- posw = pa[2]
- turtle.turnLeft()
- turtle.turnLeft()
- turtleD()
- i = i + 1
- end
- posh = posh + 1
- local a = {posl, posw, posh}
- return a
- end
- local b1 = go_height (g_length, g_width, g_height, l_pos, w_pos, h_pos)
- local b2 = go_width (g_length, g_width, g_height, l_pos, w_pos)
- l_pos = b1[1]
- w_pos = b1[2]
- h_pos = b1[3]
- write(l_pos)
- write("\t")
- write(w_pos)
- write("\t")
- print(h_pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement