Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --{program="aWallBuilder",version="1.00",date="2024-05-12"}
- -- Pastebin "6RTnhS9M"
- ---------------------------------------
- -- Turtle-automated wall builder digger.
- -- based on aTreeFarm by Kaikaku
- -- v1.04b", date="2018-01-07
- -- Pastebin Qn008fPa
- ---------------------------------------
- ---------------------------------------
- ---- PARAMETERS -----------------------
- ---------------------------------------
- local cVer ="1.00"
- local cMaxFuel = 20000
- local cMinFuel = cMaxFuel * 0.2
- local cSleep = 1 -- os.sleep value used to pace operation
- local cSlotStart = 1
- local cSlotLast = 8
- ---------------------------------------
- -- BASIC FUNCTIONS FOR TURTLE CONTROL -
- ---------------------------------------
- -- calling with no parameter moves one block forward
- local function safeForward(n)
- if n == nil
- then
- turtle.suck()
- while not turtle.forward() do os.sleep(cSleep) end
- else
- for i = 1, n do
- turtle.suck()
- while not turtle.forward() do os.sleep(cSleep) end
- end
- end
- end
- local function safeDig() -- digs forward
- turtle.suck()
- os.sleep(cSleep)
- while turtle.detect() -- might be digging into multilayered sand or gravel
- do
- turtle.dig()
- os.sleep(cSleep) -- allow blocks to fall
- end
- end
- local function safeDigDown()
- turtle.suckDown() -- might be a sapling or stick
- os.sleep(cSleep)
- turtle.digDown() -- might not be anything to dig
- end
- local function safeDigUp()
- turtle.suckUp() -- remove drek on top
- os.sleep(cSleep)
- turtle.digUp() -- might not be anything to dig
- end
- local function turtleReverse()
- turtle.turnRight()
- turtle.turnRight()
- end
- ---------------------------------------
- ---- functions ------------------------
- ---------------------------------------
- -- wait for enter to be pressed
- local function waitEnter()
- write("Press enter to start:")
- read()
- end
- -- check fuel in turtle, attempt to replenish if low
- local function checkRefuel()
- if turtle.getFuelLevel() < cMaxFuel * 0.8
- then
- print("Fuel level is low, "..turtle.getFuelLevel()..".")
- print("Use refuel all command.")
- craftFuel()
- else
- print("Fuel level ok, "..turtle.getFuelLevel()..".")
- end
- end
- local function oneBrick(brickSlot)
- turtle.select(brickSlot)
- turtle.place()
- end
- ---------------------------------------
- ---- Build a slice of the wall --------
- ---------------------------------------
- local function oneWall()
- turtle.forward() -- move to next wall and face building
- turtleReverse()
- for i = 1, 5 -- move to top of wall
- do
- turtle.up()
- end
- oneBrick(cSlotStart) -- walkway
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.up() -- rampart #1
- turtle.select(cSlotLast + 1)
- turtle.place() -- block to place against
- turtle.down()
- turtle.down()
- turtle.forward()
- turtle.turnLeft() -- orient
- turtle.select(cSlotStart + 1)
- turtle.placeUp() --rampart
- turtle.turnRight() -- orient
- turtleReverse()
- turtle.forward()
- turtle.up()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.up() -- rampart #2
- turtle.select(cSlotLast + 2)
- turtle.place() -- block to place against
- turtle.down()
- turtle.down()
- turtle.forward()
- turtle.turnRight() -- orient
- turtle.select(cSlotStart + 2)
- turtle.placeUp() --rampart
- turtle.turnLeft() -- orient
- turtleReverse()
- turtle.forward()
- turtle.up()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- for i = cSlotStart + 3, cSlotLast
- do
- turtle.down()
- oneBrick(i)
- end
- turtleReverse() -- ready for next wall segment
- end
- ---------------------------------------
- ---- main -----------------------------
- ---------------------------------------
- turtle.select(cSlotStart)
- term.clear()
- term.setCursorPos(1,1)
- if turtle.getFuelLevel() < cMinFuel
- then
- print("Fuel level "..turtle.getFuelLevel().." is too low.")
- print("Use command \"refuel all\" with 4 stacks of planks.") -- need to add fuel
- return
- end
- print("+-------------------------------------+")
- print("| aWallBuilder "..cVer..", by NortWind |")
- print("+-------------------------------------+")
- print("| Materials for auto set-up: |")
- print("| slot 1: wood for walkway |")
- print("| slot 2,3: starways for ramparts |")
- print("| slot 4-8: blocks for walls |")
- print("| slot 9-10: fence for rampart tops | ")
- print("| slot 1 count determines wall lenght |")
- print("+-------------------------------------+")
- waitEnter()
- while turtle.getItemCount(cSlotStart) > 0
- do
- oneWall()
- os.sleep(cSleep)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement