Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- spire.lua
- -- A program to build a spire using a turtle
- -- Requires a chest with fuel and building materials next to the turtle
- local height = 100 -- the height of the spire
- local floor = 10 -- the interval of floors
- local iron = 1 -- the slot for iron blocks
- local copper = 2 -- the slot for copper blocks
- local diamond = 3 -- the slot for diamond blocks
- -- Refuel from the chest if needed
- function refuel()
- if turtle.getFuelLevel() < 10 then
- turtle.turnLeft()
- turtle.suck()
- turtle.refuel()
- turtle.turnRight()
- end
- end
- -- Select a slot and place a block
- function place(slot)
- turtle.select(slot)
- turtle.placeDown()
- end
- -- Build one layer of the spire
- function layer()
- place(iron)
- turtle.forward()
- place(copper)
- turtle.forward()
- place(iron)
- turtle.turnRight()
- turtle.forward()
- place(copper)
- turtle.forward()
- place(iron)
- turtle.turnRight()
- end
- -- Build one floor of the spire
- function floor()
- for i = 1, 4 do
- layer()
- end
- end
- -- Build a staircase to the next floor
- function stairs()
- turtle.up()
- place(iron)
- turtle.forward()
- place(copper)
- turtle.up()
- end
- -- Build the spire
- function spire()
- for i = 1, height do
- refuel()
- if math.mod(i,floor) == 0 then
- floor()
- stairs()
- else
- place(iron)
- turtle.up()
- end
- end
- place(diamond) -- top off with a diamond block
- end
- spire() -- start the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement