Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Orientations = {"north","east","south","west"};
- local programData = nil;
- local function TurnLeft()
- turtle.turnLeft()
- programData.Orientation = programData.Orientation - 1;
- if programData.Orientation == -1 then
- programData.Orientation = 3;
- end
- end
- local function TurnRight()
- turtle.turnRight()
- programData.Orientation = programData.Orientation + 1;
- if programData.Orientation == 4 then
- programData.Orientation = 0;
- end
- end
- local function Save()
- local file = io.open("programData", "w")
- file:write(programData)
- file:close()
- end
- local function Load()
- local file = io.open("programData", "r") --open in read mode
- programData = file:read()
- file:close()
- end
- local function init()
- if fs.exists("programData") then
- Load()
- else
- programData = {};
- programData.Orientation = 0;
- end
- end
- local function BreakPlants()
- TurnRight();
- if turtle.detect() then
- turtle.dig();
- turtle.suck();
- end
- TurnLeft()
- TurnLeft()
- if turtle.detect() then
- turtle.dig();
- turtle.suck();
- end
- TurnRight();
- end
- local function DumpEverything()
- for i=1,16 do
- turtle.select(i);
- turtle.drop();
- end
- end
- local function Refuel()
- turtle.select(1);
- while turtle.getFuelLevel() < 500 do
- turtle.suck();
- turtle.refuel();
- end
- end
- local function BlockAction()
- local success, data = turtle.inspect();
- if data.name == "minecraft:obsidian" then
- TurnLeft()
- TurnLeft()
- elseif data.name == "EnderStorage:EnderStorage" then
- DumpEverything();
- Refuel();
- TurnLeft();
- TurnLeft();
- else
- error("Unknown block in front");
- end
- end
- init();
- while true do
- BreakPlants()
- if turtle.detect() then
- BlockAction()
- end
- turtle.forward()
- end
Advertisement
Add Comment
Please, Sign In to add comment