Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Move Bot
- function moveToChest()
- newX = botCoords["x"] - chestCoords["x"]
- newY = botCoords["y"] - chestCoords["y"]
- newZ = botCoords["z"] - chestCoords["z"]
- if newX > 0 then
- iWantToFace = 3
- else if newX < 0 then
- iWantToFace = 1
- end
- if newY > 0 then
- iWantToFace = 0
- else if newY < 0 then
- iWantToFace = 2
- end
- if newZ > 0 then
- turtle.down()
- botCoords["z"] = botCoords["z"] - 1
- else if newZ < 0 then
- turtle.up()
- botCoords["z"] = botCoords["z"] + 1
- end
- if facing == iWantToFace then
- turtle.forward()
- if facing == 0 then
- botCoords["y"] = botCoords["y"] - 1
- else if facing == 1 then
- botCoords["x"] = botCoords["x"] + 1
- else if facing == 2 then
- botCoords["y"] = botCoords["y"] + 1
- else if facing == 3 then
- botCoords["x"] = botCoords["x"] - 1
- end
- else then
- turtle.turnRight()
- facing = facing + 1
- if facing > 3 then
- faceing = facing - 4
- end
- end
- end
- --Main Program
- botCoords = {}
- homeCoords = {}
- chestCoords = {}
- facing = 0
- iWantToFace = 0
- pathBack = {}
- print("Gathering Coordinates")
- file = fs.open("Locations", "r")
- file.readLine()
- x = tonumber(file.readLine())
- botCoords["x"] = x
- homeCoords["x"] = x
- y = tonumber(file.readLine())
- botCoords["y"] = y
- homeCoords["y"] = y
- z = tonumber(file.readLine())
- botCoords["z"] = z
- homeCoords["z"] = z
- file.readLine()
- chestCoords["x"] = tonumber(file.readLine())
- chestCoords["y"] = tonumber(file.readLine())
- chestCoords["z"] = tonumber(file.readLine())
- goBackAt = 0
- isGoingBack = false
- needTask = false
- getResource = false
- while true do
- if turtle.getFuelLevel() == 0 and turtle.getItemCount(16) > 0 then
- goBackAt = (turtle.getItemCount(16) * 80) / 2
- turtle.select(16)
- turtle.refuel(turtle.getItemCount(16))
- print("YUM")
- print(turtle.getFuelLevel())
- elseif turtle.getFuelLevel() == 0 then
- print("Sleepy Time")
- os.sleep(60)
- elseif turtle.getFuelLevel() <= goBackAt or isGoingBack then
- isGoingBack = true
- moveToChest()
- if turtle.detect() then
- data = turtle.inspect()
- if data.name == "Minecraft:Chest" then
- chest = peripheral.isPresent("front")
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- for slot, item in pairs(chest.getAllStacks()) do
- if item.id == "Minecraft:Coal"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement