Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DISTANCETOHOMEBASE = 0
- function MoveDownwardByOne()
- if CheckRetreatParameters() or CheckForBedrockBeneath() then
- print("Critical Error")
- local x,y,z = gps.locate()
- SavedX = x
- SavedY = y
- SavedZ = z
- print("close To retreating")
- Retreat()
- end
- if turtle.getFuelLevel() < 20 then
- Refuel()
- end
- local existence = turtle.inspectDown()
- if existence then
- turtle.digDown()
- end
- turtle.down()
- end
- function CheckRetreatParameters()
- local lowFuel = LowFuel()
- local fullInventory = InventoryHasfreeSpace()
- if lowFuel then
- print("Fuel")
- return true
- end
- if fullInventory then
- print("Inventory")
- return true
- end
- end
- function CheckForBedrockBeneath()
- local success,data = turtle.inspectDown()
- if success then
- if data.name == "minecraft:bedrock" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function LowFuel()
- local extraSafetyDistance = 10
- if DISTANCETOHOMEBASE < CalculateTotalFuel() + extraSafetyDistance then
- return false
- else if DISTANCETOHOMEBASE >= CalculateTotalFuel() + extraSafetyDistance then
- return true
- end
- end
- end
- function CalculateTotalFuel()
- local result = turtle.getFuelLevel() + turtle.getItemCount(1) * 80
- return result
- end
- function InventoryHasfreeSpace()
- local count = turtle.getItemCount(16)
- if count == 0 then
- return false
- else
- return true
- end
- end
- function CalculateHomebaseDistance(baseX,BaseY,BaseZ)
- local x,y,z = gps.locate()
- local result = CalculateTotalDistance(CalculateDistance(baseX,x),CalculateDistance(BaseY,y),CalculateDistance(BaseZ,z))
- end
- function init()
- end
- init()
- MoveDownwardByOne()
Advertisement
Add Comment
Please, Sign In to add comment