Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --To build stairs, need width of stairwell, height of stairwell, depth of stairwell
- local tArgs = {...}
- -- Deal with arguments and variables
- local args = tArgs
- local curr_height,curr_width,curr_depth = 1
- local direction = nil
- local dig = nil
- -- error handling
- local syntax_error="Invalid syntax. Try using:\n stairs X Y Z\n X = Height of stairwell\n Y = Width of stairwell\n Z = Depth of stairwell\n\nX, Y, and Z must be integers"
- -- right # & type of arguments?
- function initialize()
- if #args ~= 3 or tonumber(value)==nil then
- return print(syntax_error)
- else
- -- set measurements
- local height = tonumber(args[1])
- local width = tonumber(args[2])
- local depth = tonumber(args[3])
- -- get direction
- print("<U>p or <D>own?")
- local input=string.lower(read())
- responses = {"up"=true,"down"=true,"u"=true,"d"=true}
- -- return lowercase first character to determine stairwell direction
- if responses.input then
- direction = string.sub(input,1,1)
- return direction
- end
- end
- -- dig one column to specified height
- function column(direction, height)
- if direction == "u" then
- while curr_height < height do
- turtle.digUp()
- turtle.moveUp()
- curr_height = curr_height + 1
- end
- while curr_height ~=1 do
- turtle.moveDown()
- curr_height = curr_height - 1
- end
- else
- while curr_height < height - 1 do
- turtle.digDown()
- turtle.digUp()
- turtle.moveUp()
- curr_height = curr_height + 1
- end
- end
- return
- end
- -- digs riser to width and height
- function digriser(width)
- for col=1, width, 1 do
- column()
- turtle.turnRight()
- turtle.moveForward()
- turtle.turnLeft()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.moveForward(width - 1)
- turtle.turnRight()
- turtle.dig()
- turtle.moveForward()
- return
- end
- -- digs out the stairs
- function digstairs(depth)
- while curr_depth ~= depth do
- digriser(width)
- curr_dept = curr_depth + 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement