Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Builds a platform or fills a non flat surface.
- --place turtle on last block before the span
- --this is my first lua app ;)
- --this may be upgraded to predetermine length needed for unknown span or wider path etc.
- local function block()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- end
- local function move()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- local tArgs = { ... }
- if #tArgs < 1 then
- print( "Usage: bridge <length> <width>" )
- return
- end
- local length = tonumber( tArgs[1] )
- if length < 1 then
- print( "Bridge length must be positive." )
- return
- end
- local width = 1
- if #tArgs == 2 then
- width = tonumber( tArgs[2] )
- if width < 1 then
- print( "Bridge width must be positive." )
- return
- end
- end
- local blocks = 0
- for n=1,16 do
- blocks = blocks + turtle.getItemCount(n)
- end
- if blocks < length * width then
- print( "There must be at least "..(length * width).." blocks in the slots." )
- return
- else
- local slot = 1
- local right = true
- move()
- block()
- for x=1,width do
- for z=1,length - 1 do
- while turtle.getItemCount(slot) < 1 do
- slot = slot + 1
- end
- turtle.select(slot)
- move()
- block()
- end
- if x ~= width then
- if right then
- turtle.turnRight()
- move()
- turtle.turnRight()
- else
- turtle.turnLeft()
- move()
- turtle.turnLeft()
- end
- sleep(0.1)
- block()
- right = not right
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement