Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local coord = { 0, 0, 0 }
- local dir = 0
- if not startDir then coord[3] = -coord[3] end
- function curMoveAxis()
- if dir % 2 == 0 then
- return 1
- else
- return 3
- end
- end
- function curMoveDir()
- if math.floor( dir / 2 ) % 2 == 0 then
- return 1
- else
- return -1
- end
- end
- function forward()
- while not turtle.forward() do sleep( 1 ) end
- local axis = curMoveAxis()
- coord[ axis ] = coord[ axis ] + curMoveDir()
- end
- function backward()
- while not turtle.back() do sleep( 1 ) end
- local axis = curMoveAxis()
- coord[ axis ] = coord[ axis ] - curMoveDir()
- end
- function up()
- while not turtle.up() do sleep( 1 ) end
- coord[ 2 ] = coord[ 2 ] + 1
- end
- function down()
- while not turtle.down() do sleep( 1 ) end
- coord[ 2 ] = coord[ 2 ] - 1
- end
- function turnLeft()
- turtle.turnLeft()
- dir = ( dir + 1 ) % 4
- end
- function turnRight()
- turtle.turnRight()
- dir = ( dir - 1 ) % 4
- end
- function turn( _dir )
- if _dir then
- turnLeft()
- else
- turnRight()
- end
- end
- function moveToSlot( to, fromMin, fromMax )
- if not fromMax then fromMax = 16 end
- for i = fromMin, fromMax do
- if turtle.getItemCount( to ) == 64 then break end
- if ( not i == to ) and turtle.getItemCount( i ) > 0 then
- turtle.select( i )
- turtle.transferTo( to, 64 )
- end
- end
- turtle.select( to )
- end
- function stepsToPos( newCoord )
- local axis = curMoveAxis()
- return ( coord[ axis ] - newCoord[ axis ] ) * curMoveDir()
- end
- function moveTo( newCoord, callback )
- function callCallback()
- if callback ~= nil then callback( newCoord ) end
- end
- while newCoord[ 2 ] > coord[ 2 ] do
- up()
- callCallback()
- end
- for i = 1, 2 do
- local axis = curMoveAxis()
- while stepsToPos( newCoord ) > 0 do
- backward()
- callCallback()
- end
- while stepsToPos( newCoord ) < 0 do
- forward()
- callCallback()
- end
- turn(true)
- end
- while newCoord[ 2 ] < coord[ 2 ] do
- down()
- callCallback()
- end
- end
- local height = tArgs[1]
- if height then height = tonumber( height ) else height = 40 end
- function placeBlock( c )
- moveToSlot( 1, 2, 15 )
- end
- function placeMarker()
- turtle.select( 16 )
- turtle.placeDown()
- turtle.select( 1 )
- end
- moveTo( { 0, height, 0 }, placeBlock )
- moveTo( { 64, height, 0 }, placeBlock )
- up()
- placeMarker()
- moveTo( { 0, height + 1, 0 } )
- placeMarker()
- turnRight()
- forward()
- down()
- placeBlock()
- moveTo( { 0, height, 64 }, placeBlock )
- up()
- placeMarker()
- moveTo( { 0, height + 1, 0 } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement