Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- nArgs = #args
- version = "pillar: Rev 0.1"
- materialSlot = 1
- spacing = 8
- function placePillar()
- local y = 0
- while turtle.down() do
- y = y-1
- if y < -20 then
- break
- end
- end
- turtle.select(1)
- while y < 0 do
- turtle.up()
- if ensureMaterial() then
- turtle.placeDown()
- end
- y = y+1
- end
- end
- function forward(nBlocks)
- local i = 0
- for i=1,nBlocks do
- turtle.forward()
- end
- end
- function ensureMaterial()
- if turtle.getItemCount(materialSlot) < 3 then
- organizeMaterial()
- end
- if turtle.getItemCount(materialSlot) < 3 then
- print("No more material")
- return false
- end
- return true
- end
- function organizeMaterial()
- local i
- materialCount = turtle.getItemCount(materialSlot)
- if materialCount < 3 then
- for i=2,16 do
- turtle.select(i)
- if turtle.compareTo(materialSlot) then
- turtle.transferTo(materialSlot)
- end
- end
- end
- turtle.select(materialSlot)
- end
- -- ================= Main Program ===================
- if nArgs == 0 or (nArgs == 1 and args[1]== "help") then
- print(version)
- print("Fill all slots with building material.")
- return
- end
- --[[
- if nArgs < 2 or nArgs > 3 then
- print(usage)
- return
- end
- --]]
- nPillars = tonumber(args[1])
- if nPillars == nil then
- print("\"", args[1], "\" is not a valid number.")
- return
- end
- if nPillars < 1 then
- print("Number of pillars must be a positive integer.")
- end
- for i=1,nPillars do
- placePillar()
- if i < nPillars then
- forward(spacing)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement