Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variables
- Curslot = 1
- --Movement functions
- function moveForward(forward)
- for fw = 1, forward do
- turtle.forward()
- end
- end
- function moveUp(up)
- for up = 1, up do
- turtle.up()
- end
- end
- function moveDown(down)
- for dw = 1, down do
- turtle.down()
- end
- end
- --Movement functions
- function gotoGround()
- repeat
- turtle.down()
- until
- turtle.detectDown() == true
- turtle.up()
- end
- function refillMaterials()
- local getItem = turtle.getItemCount(Curslot)
- if getItem < 1 then
- print("No items in current slot.")
- print("Calculating.")
- if Curslot == 16 then
- turtle.select(1)
- noMaterials()
- else
- Curslot = Curslot + 1
- print("Switching to slot ", Curslot)
- turtle.select(Curslot)
- end
- end
- end
- function noMaterials()
- term.clear()
- term.setCursorPos(1,1)
- print("[Error].")
- print("Out of materials please bring me more :(")
- print("press any key to continue...")
- event1, param1 = os.pullEvent()
- refillMaterials()
- end
- function placeBlock(times)
- for blocks = 1, times do
- refillMaterials()
- turtle.placeDown()
- turtle.forward()
- end
- end
- -- Build cylinder code
- function corner()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- placeBlock(1)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- placeBlock(1)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- placeBlock(1)
- turtle.turnRight()
- turtle.forward()
- end
- function buildCylinderLayer()
- placeBlock(6)
- corner()
- placeBlock(6)
- corner()
- placeBlock(6)
- corner()
- placeBlock(6)
- corner()
- end
- function buildCylinder(cylinderHeight)
- for cylheight = 1, cylinderHeight do
- buildCylinderLayer()
- turtle.up()
- end
- end
- -- Build cylinder code
- -- Build wall code
- function wallLayer(wlength)
- for Wlen = 1, wlength do
- placeBlock(19)
- turtle.placeDown()
- wallCorner()
- placeBlock(19)
- turtle.forward()
- turtle.placeDown()
- wallCorner()
- turtle.up()
- end
- end
- function wallCorner()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- end
- function wallDirection( direction )
- if direction == 1
- print("going left")
- turtle.turnLeft()
- moveForward(1)
- gotoGround()
- end
- if direction == 2
- print("going forward")
- moveForward(9)
- turtle.turnRight()
- moveForward(4)
- turtle.turnLeft()
- turtle.forward()
- gotoGround()
- end
- if direction == 3
- print("going right")
- moveForward(5)
- turtle.turnRight()
- moveForward(14)
- gotoGround()
- end
- if direction == 4 then
- print("going back")
- turtle.turnRight(2)
- moveForward(4)
- turtle.turnLeft()
- moveForward(9)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- moveForward(1)
- gotoGround()
- end
- end
- function buildWall( wallHeight )
- for wallH = 1, wallHeight do
- wallLayer()
- end
- end
- -- Build wall code
- function nextCylinder(size)
- function generateCastle(size)
- term.clear()
- term.setCursorPos(1,1)
- print("How tall should the Castle be?")
- local height = tonumber(read())
- turtle.select(1)
- -- Start building!
- gotoGround()
- buildCylinder(height)
- wallDirection( math.random (1,4) )
- wallLayer(height)
- end
- end
- -- Done Building
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement