Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local numBlocks = 0
- local function pbBuildRow(length)
- if length > 0 then
- shell.run("go", "[_9_8_7_6_5_4_3_2_1f]" .. length-1)
- shell.run("go", "[_9_8_7_6_5_4_3_2_1]")
- else
- print("Plane length must be at least one")
- end
- end
- local function pbCheckInventory()
- numBlocks = 0
- for j=1,9 do
- numBlocks = numBlocks + turtle.getItemCount(j)
- end
- if numBlocks < planeLength then
- print("Not enough blocks to complete the next row, please add more blocks to slots 1 through 9 and press a key to continue")
- event = os.pullEvent()
- if event == "char" then
- pbCheckInventory()
- end
- else
- return true
- end
- end
- local function pbNextLayer()
- shell.run("go", "ua")
- end
- local function pbNextRow(direction)
- if direction == 1 then
- shell.run("go", "rfr")
- else
- shell.run("go", "lfl")
- end
- end
- if fs.exists("go") then
- if #tArgs < 2 or #tArgs > 4 then
- shell.run("clear")
- print("The number of parameters must be 2-4, first length then height, then optionally an orientation character, 'h' for horizontal, 'v' for vertical (default). Then the direction relative to the turtle for the plane to extend: l for left or 'r' for right (default).")
- return false
- end
- planeLength = tonumber(tArgs[1])
- planeHeight = tonumber(tArgs[2])
- planeOrientation = "v"
- -- turn dir is specified by the parameter and represents the direction from the turtle's start position that the horizontal planes are placed in
- -- the decision whether to turn right or left at the end of a row is decided by the modulus of a division by 2 of the row count, modified by the turnDir
- turnDir = "r"
- -- turnDir has a default value, as does planeOrientation, but turnDir is only ever used when planeOrientation is set to horizontal
- if #tArgs > 2 then
- planeOrientation = tArgs[3]
- end
- if #tArgs > 3 then
- turnDir = tArgs[4]
- end
- -- For the 'height' aka depth dimension, do a row of the specified length of blocks
- for i=1,planeHeight do
- -- Place the row of blocks for the specified row length regardless of plane orientation
- pbCheckInventory()
- pbBuildRow(planeLength)
- -- If the orientation is vertical, call the function to continue the plane in that direction, and when coming to the end of the plane, go back to near the starting location
- if planeOrientation == "v" then
- pbNextLayer()
- -- If the orientation is horizontal, call the function to continue the plane in that direction, and when coming to the end of the plane, go back to near the starting location
- else
- if turnDir == "r" then
- pbNextRow((i+2)%2)
- else
- pbNextRow((i+1)%2)
- end
- end
- end
- else
- shell.run("clear")
- print("You must install rob's modified version of the 'go' utility program, located on pastebin at t0vyUwmt")
- end
Advertisement
Add Comment
Please, Sign In to add comment