Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- By: skylarsch
- Usage: room <length (9)> <width (9)> <height (5)>
- Each of the arguments are optional, but if you must specify all the values before the one you want to change.
- --]]
- -- MARK: Helper Functions
- function fwd() -- Move forward
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function move(ammount) -- Move forward by the number of blocks
- for i = 0, ammount, 1 do
- fwd()
- end
- end
- function refuel() -- Refuel the turtle if it needs it
- local slot = 1
- while turtle.getFuelLevel() < 50 do
- if slot > 16 then
- print("Failed to refuel turtle")
- turtle.select(1)
- return false
- end
- turtle.select(slot)
- if not turtle.refuel(1) then
- slot = slot + 1
- end
- end
- turtle.select(1)
- return true
- end
- function up()
- while not turtle.up() do
- turtle.digUp()
- end
- end
- function down()
- while not turtle.down() do
- turtle.digDown()
- end
- end
- function goDown(ammount)
- for i = 0, ammount, 1 do
- down()
- end
- end
- function makeFloor(l, w)
- for i = 0, w + 1, 1 do
- move(l)
- if (i % 2 == 0) then
- if i <= w then
- turtle.turnRight()
- fwd()
- turtle.turnRight()
- else
- turtle.turnLeft()
- move(w)
- turtle.turnLeft()
- move(l)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- else
- if i <= w then
- turtle.turnLeft()
- fwd()
- turtle.turnLeft()
- else
- turtle.turnRight()
- move(w)
- turtle.turnRight()
- end
- end
- refuel()
- end
- end
- -- MARK: Main App
- local argv = {...}
- local length = (argv[1] or 54) - 2
- local width = (argv[2] or 35) - 2
- local height = (argv[3] or 4) - 1
- print("Creating Room:")
- print(" "..(length + 2).."x"..(width + 2).."x"..(height + 1))
- if not refuel() then
- print("Aborting...")
- return
- end
- for floor = 0, height, 1 do
- makeFloor(length, width)
- if floor < height then
- up()
- else
- goDown(height - 1)
- end
- if not refuel() then
- print("Aborting...")
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement