Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --functions
- local refuel -- refuels the turtle if it gets below 10
- local depth -- gets the depth variable (d)
- local length -- gets the length variable(l)
- local width -- gets the width variable (w)
- local length1 -- lays blocks along the length wall using the (l) variable
- local width1 -- lays blocks along the width wall using the (w) variable
- local slots -- checks the slot for items and moves to the next slot when empty
- local wall -- puts it all together and rasied the height of t he turtle using the (d) variable
- --Varaibles
- local d = 1 --depth variable
- local l = 1 -- length variable
- local w = 1 --Width varable
- local s = 1 -- Slot variable
- local a = 0 -- returns the total amount of blocks required for the build.
- local diag = 1 -- returns the length plus width count to place into the minimum refuel check. This ensures that the refueling is done in the corners.
- local xCoord = -459
- local zCoord = 63
- local yCoord = -376
- local xhome = xCoord
- local zhome = zCoord
- local yhome = yCoord
- local orientation = 3
- local zDiff = {-1, 0, 1, 0}
- local xDiff = {0, 1, 0, -1}
- local yMin = yCoord
- local xProgress = 999
- local zProgress = 999
- local yProgress = 999
- local oProgress = 1
- local yTvl = 85
- orientations = {"north","east","south","west"}
- function empty()
- turtle.select(16)
- if turtle.getItmeCount() ~= 0 then
- turtle.select(s)
- return
- end
- end
- function look(direction)
- while direction ~= orientations[orientation] do
- right()
- end
- end
- function left()
- orientation = orientation - 1
- orientation = (orientation - 1)%4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function right()
- orientation = orientation - 1
- orientation = (orientation + 1)%4
- orientation = orientation + 1
- turtle.turnRight()
- end
- function fwd()
- xCoord = xCoord + xDiff[orientation]
- zCoord = zCoord + zDiff[orientation]
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- end
- function moveUp()
- yCoord = yCoord +1
- moved = false
- while not(moved) do
- moved = turtle.up()
- end
- end
- function moveDown()
- yCoord = yCoord -1
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- if yMin > yCoord then
- yMin = yCoord
- end
- end
- function moveto(xtgt, ztgt, ytgt)
- while ytgt < yCoord do
- moveDown()
- end
- while ytgt > yCoord do
- moveUp()
- end
- while xtgt < xCoord do
- if xtgt < xCoord then
- look("west")
- while xtgt < xCoord do
- fwd()
- end
- end
- if xtgt > xCoord then
- look("east")
- while xtgt > xCoord do
- fwd()
- end
- end
- end
- if ztgt < zCoord then
- look ("north")
- while ztgt < zCoord do
- fwd()
- end
- end
- if ztgt > zCoord then
- look("south")
- while ztgt > zCoord do
- fwd()
- end
- end
- end
- function restock()
- xProgress = xCoord
- zProgress = zCoord
- yProgress = yCoord
- oProgress = orientation
- moveto(xHome, zHome, yTvl)
- moveto(xHome, zHome,yHome)
- while turtle.getItemCount(16) ~= 64 do
- print ("Stocking up")
- end
- turtle.select(2)
- s=2
- moveto(xProgress, zProgress, yTvl)
- moveto(xProgress, zProgress, yProgress)
- look(orientations[oProgress])
- end
- function refuel()
- if turtle.getFuelLevel() < 10 then
- turtle.refuel(1)
- end
- end
- function refuel3()
- if turtle.getFuelLevel() > diag then
- print("The fuel level is: "..turtle.getFuelLevel())
- return
- else
- turtle.select(1)
- turtle.refuel(1)
- turtle.select(s)
- print("Refuelled. New level is: "..turtle.getFuelLevel())
- return
- end
- end
- function depth()
- fwd()
- while turtle.detectDown() ~= true do
- moveDown()
- d = d+1
- refuel()
- os.sleep(0.5)
- end
- end
- function length()
- right()
- while turtle.detect() ~= true do
- fwd()
- l=l+1
- refuel()
- os.sleep(0.5)
- end
- end
- function width()
- left()
- while turtle.detect() ~= true do
- fwd()
- w=w+1
- refuel()
- os.sleep(0.5)
- end
- end
- function slots()
- if turtle.getItemCount(s) == 0 then
- if s < 16 then
- turtle.select(s+1)
- s = s+1
- return
- else
- restock()
- end
- os.sleep(0.5)
- end
- end
- function length1()
- for i=1,(l-1) do
- slots()
- turtle.placeDown()
- fwd()
- os.sleep(0.5)
- end
- end
- function width1()
- for i=1, (w-1) do
- slots()
- turtle.placeDown()
- fwd()
- os.sleep(0.5)
- end
- end
- function wall()
- left()
- moveUp()
- for i=1,d-1 do
- length1()
- left()
- width1()
- left()
- --os.sleep(10) -- debugging
- refuel3()
- length1()
- left()
- width1()
- left()
- turtle.up()
- refuel3()
- end
- fwd()
- end
- turtle.select(s)
- turtle.refuel(1)
- turtle.select(2)
- s = 2
- depth()
- length()
- width()
- diag = l+w -- sets the refuel check number
- wall()
- print ("length is"..l)
- print("width is"..w)
- print("diag value is"..diag)
Advertisement
Add Comment
Please, Sign In to add comment