Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local digX = 64 --multiple van 2
- local digY = 40
- local digZ = 64 --multiple van 4
- --[[
- ░ █ ▄ ▀
- place facing south
- inefficient furthest corner
- flopping weener
- turtle inventory slots:
- -------------
- |01|02|03|04|
- -------------
- |05|06|07|08|
- -------------
- |09|10|11|12|
- -------------
- |12|14|15|16|
- -------------
- fuel chest in 15
- refueling in 14
- drop chest in 16
- inventory up to 13
- all moving will involve digging and checking, stuff in its path will be destroyed
- coordinates and facing directions are updated inside the functions
- x -> travel east and x increases, travel west and x decreases
- y -> height
- z -> travel south and z increases, travel north and z decreases
- for cardinal direction facing:
- 1=north
- 2=east
- 3=south
- 4=west
- when moving forward, x and z change depending on facing:
- 1=North, z=z-1
- ^
- |
- 4=west, x=x-1 <-- --> 2=east, x=x+1
- |
- v
- 3=south, z=z+1
- quary length and width are positive
- when digging the quarry in north and west directions, stopping values are zll and xll, zll = zhl - digZ, same for x
- zhl is start coordinate
- xhl is start coordinate
- ]]
- --facing = 3 --face south when placed
- facing = 1 --face north blabla
- facings = {"north", "east", "south", "west"} --needs local??
- directions = {"north", "east", "south", "west"}
- dx = {0, 1, 0, -1} --these values come directly from the above shown windroos
- dz = {-1, 0, 1, 0} --e.g. if facing north and moving forward dx=0 and dz=-1
- local maxInventorySlot = 13 --13 for drop() function, this is the last inventory slot to be used
- local fuelSlot = 14
- local fuelChestSlot = 15 --for reFuel()function
- local dropChestSlot = 16 --drop chest slot piggfucker
- local xt = 0 --turtle start 588
- local xhl = 0 --quarry start -16
- local xll = -2 --multiples van 2
- local yt = 54 --turtle start was 70
- local yhl = 54 --quarry start
- local yll = -2
- local zt = 0 --turtle start was 583
- local zhl = 605 --quarry start 590
- local zll = -4 --moet in multiples van 4
- local yTravel = 80
- function turtleLeft() --CW = positive, CCW = negative
- facing = facing - 1 --silly table starts at 1,
- facing = (facing - 1) % 4 --but division remainder does not...
- facing = facing + 1 --substract 1 first, add it back when done
- turtle.turnLeft()
- end
- function turtleRight()
- facing = facing - 1
- facing = (facing + 1) % 4
- facing = facing + 1
- turtle.turnRight()
- end
- function face(direction)
- if direction == "north" then dir = 1
- elseif direction == "east" then dir = 2
- elseif direction == "south" then dir = 3
- elseif direction == "west" then dir = 4
- else
- end
- if dir - facing == 1 or dir - facing == -3 then
- while direction ~= facings[facing] do
- turtleRight()
- end
- else
- while direction ~= facings[facing] do
- turtleLeft()
- end
- end
- end
- function turtleUp()
- local moved = false
- while not(moved) do
- turtle.digUp()
- drop()
- moved = turtle.up()
- reFuel()
- sleep(0.1)
- end
- yt = yt + 1
- end
- function turtleUpNoDrop()
- local moved = false
- while not(moved) do
- turtle.digUp()
- moved = turtle.up()
- reFuel()
- sleep(0.1)
- end
- yt = yt + 1
- end
- function turtleDown()
- local moved = false
- while not(moved) do
- turtle.digDown()
- drop()
- moved = turtle.down()
- reFuel()
- sleep(0.1)
- end
- yt = yt - 1
- end
- function turtleDownNoDrop()
- local moved = false
- while not(moved) do
- turtle.digDown()
- moved = turtle.down()
- reFuel()
- sleep(0.1)
- end
- yt = yt - 1
- end
- function turtleForward()
- local moved = false
- while not(moved) do
- turtle.dig()
- drop()
- moved = turtle.forward()
- reFuel()
- end
- xt = xt + dx[facing] --change in location will be looked up in tables
- zt = zt + dz[facing] --dx and dz, dependend on facing value
- end
- function turtleForwardNoDrop()
- local moved = false
- while not(moved) do
- turtle.dig() --this should fix the fucking gravel from stopping my turtle
- --drop()
- moved = turtle.forward()
- reFuel()
- end
- xt = xt + dx[facing] --change in location will be looked up in tables
- zt = zt + dz[facing] --dx and dz, dependend on facing value
- end
- function digDown() --double dick down, down and then forward for superefficiency
- local moved = false
- while not(moved) do
- turtle.digDown()
- drop()
- moved = turtle.down()
- reFuel()
- turtle.dig()
- drop()
- end
- yt = yt - 1
- end
- function digUp() --double dick up, up and then forward for superefficiency
- local moved = false
- while not(moved) do
- turtle.digUp()
- drop()
- moved = turtle.up()
- reFuel()
- turtle.dig()
- drop()
- end
- yt = yt + 1
- end
- function drop() --when last inventory slot has an item, place an enderchest and dump all
- if turtle.getItemCount(maxInventorySlot) > 0 then
- local moved = false
- while not(moved) do
- turtle.digUp()
- moved = turtle.up()
- reFuel()
- sleep(0.1)
- end
- yt = yt + 1
- turtle.select(dropChestSlot)
- turtle.placeDown()
- local slot = 1
- while slot <= maxInventorySlot do
- turtle.select(slot)
- turtle.dropDown()
- slot = slot + 1
- end
- turtle.select(dropChestSlot)
- turtle.digDown()
- turtle.select(1) --start filling those slots again
- turtle.down()
- yt = yt - 1
- end
- end
- function dropNoEnder()
- if turtle.getItemCount(maxInventorySlot) > 0 then
- xSite = xt
- zSite = zt
- ySite = yt
- facingSite = facing
- gotoHomeNoDrop()
- face("north")
- local slot = 1
- while slot <= maxInventorySlot do
- turtle.select(slot)
- turtle.drop()
- slot = slot + 1
- end
- gotoSite()
- while facings[facing] ~= facings[facingSite] do
- turtleLeft()
- end
- turtle.select(1) --start filling those slots again
- end
- end
- function gotoHome()
- gotoY(yTravel)
- gotoX(xHome)
- gotoZ(zHome)
- gotoY(yHome)
- end
- function gotoHomeNoDrop()
- gotoYNoDrop(yTravel)
- gotoXNoDrop(xHome)
- gotoZNoDrop(zHome)
- gotoYNoDrop(yHome)
- end
- function gotoSite()
- gotoY(yTravel)
- gotoZ(zSite)
- gotoX(xSite)
- gotoY(ySite)
- end
- function reFuel()
- if turtle.getFuelLevel() < 20 then
- if turtle.getItemCount(fuelSlot) == 0 then
- local moved = false
- while not(moved) do
- turtle.digUp()
- moved = turtle.up()
- sleep(0.1)
- end
- yt = yt + 1
- turtle.select(15) --(fuelChestSlot)
- turtle.placeDown()
- turtle.select(14) --(fuelSlot)
- turtle.suckDown()
- turtle.select(15) --(fuelChestSlot)
- turtle.digDown()
- turtle.down()
- yt = yt - 1
- else
- end
- turtle.select(14) --(fuelSlot)
- turtle.refuel()
- turtle.select(1)
- else
- end
- end
- function digPlaneToNorth()
- face("north") --facing north will reduce z
- while zt > zll + 1 do --1:0 > -8 + 1 is true
- while yt > yll do
- digDown()
- end
- turtleForward() ---1 -5
- turtleForward() ---2 -6
- turtle.dig()
- while yt < yhl do
- digUp()
- end
- turtleForward() ---3 -7
- if zt ~= zll + 1 then --was -7
- turtleForward() ---4 -8
- else
- end
- end
- end
- function digPlaneToSouth()
- face("south") --facing north will reduce z
- while zt < zhl - 1 do -- -7 < 0 - 1 is true
- while yt > yll do
- digDown()
- end
- turtleForward() ---6 -2
- turtleForward() ---5 -1
- turtle.dig()
- while yt < yhl do
- digUp()
- end
- turtleForward() ---4 0
- if zt ~= zhl then --
- turtleForward() ---3 +1
- else
- end
- end
- end
- function gotoX(Xtarget)
- while xt > Xtarget do
- face("west")
- while xt > Xtarget do
- turtleForward()
- end
- end
- while xt < Xtarget do
- face("east")
- while xt < Xtarget do
- turtleForward()
- end
- end
- end
- function gotoXNoDrop(Xtarget)
- while xt > Xtarget do
- face("west")
- while xt > Xtarget do
- turtleForwardNoDrop()
- end
- end
- while xt < Xtarget do
- face("east")
- while xt < Xtarget do
- turtleForwardNoDrop()
- end
- end
- end
- function gotoZ(Ztarget)
- while zt > Ztarget do
- face("north")
- while zt > Ztarget do
- turtleForward()
- end
- end
- while zt < Ztarget do
- face("south")
- while zt < Ztarget do
- turtleForward()
- end
- end
- end
- function gotoZNoDrop(Ztarget)
- while zt > Ztarget do
- face("north")
- while zt > Ztarget do
- turtleForwardNoDrop()
- end
- end
- while zt < Ztarget do
- face("south")
- while zt < Ztarget do
- turtleForwardNoDrop()
- end
- end
- end
- function gotoY(Ytarget)
- while yt > Ytarget do
- turtleDown()
- end
- while yt < Ytarget do
- turtleUp()
- end
- end
- function gotoYNoDrop(Ytarget)
- while yt > Ytarget do
- turtleDownNoDrop()
- end
- while yt < Ytarget do
- turtleUpNoDrop()
- end
- end
- function digCube()
- while xt > xll + 1 do -- while 0 > -4 true
- digPlaneToNorth()
- face("west")
- turtleForward() -- x=-1 -3
- digPlaneToSouth()
- if xt ~= xll + 1 then
- face("west")
- turtleForward() -- x=-2 -4
- else
- end
- end
- end
- function quarryStart()
- xhl = xt
- yhl = yt
- zhl = zt
- xll = xhl - digX
- yll = yhl - digY
- zll = zhl - digZ
- digCube()
- end
- function finalDrop()
- local slot = 1
- face("north")
- while slot <= maxInventorySlot do
- turtle.select(slot)
- turtle.drop()
- slot = slot + 1
- end
- end
- function finaldrop2()
- local moved = false
- while not(moved) do
- turtle.digUp()
- moved = turtle.up()
- reFuel()
- sleep(0.1)
- end
- yt = yt + 1
- turtle.select(dropChestSlot)
- turtle.placeDown()
- local slot = 1
- while slot <= maxInventorySlot do
- turtle.select(slot)
- turtle.dropDown()
- slot = slot + 1
- end
- turtle.select(dropChestSlot)
- turtle.digDown()
- turtle.select(1) --start filling those slots again
- turtle.down()
- yt = yt - 1
- end
- xHome = xt
- zHome = zt
- yHome = yt
- term.clear()
- quarryStart()
- face("south")
- finaldrop2()
- --------facing test---------
- --[[
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Select direction: north 1 /east 2 /south 3 /west 4 ")
- print("Current direction: "..facing)
- term.write(" ")
- direction = tostring(read())
- print(" ")
- face(direction)
- end
- --]]
Add Comment
Please, Sign In to add comment