Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args={...};
- local config, width, height, checkThread;
- --[[
- TODO:
- Home when full
- Enderchest when full
- Send to diplay
- Torches
- Ladder
- Auto refuel with lava
- Drop useless items
- ]]
- local function goHome() --Move the turtle to the start position
- --Z pos
- while(mov.getZ()~=0)
- do
- if (mov.getZ()<0)
- then
- mov.u(true);
- elseif (mov.getZ()>0)
- then
- mov.d(true);
- end
- end
- --X pos
- if (mov.getX()<0)
- then
- mov.pointTo(mov.LEFT);
- elseif (mov.getY()>0)
- then
- mov.pointTo(mov.RIGHT);
- end
- while(mov.getX()~=0)
- do
- mov.f(true);
- end
- --Y pos
- if (mov.getY()<0)
- then
- mov.pointTo(mov.UP);
- elseif (mov.getY()>0)
- then
- mov.pointTo(mov.DOWN);
- end
- while(mov.getY()~=0)
- do
- mov.f(true);
- end
- mov.pointTo(mov.UP);
- mov.l();
- --dropAll(false);
- mov.r();
- --returnBack(x, y, dir);
- end
- local function returnBack(x, y, dir) --Go to coords
- --Y pos
- if (mov.getY()<y)
- then
- mov.pointTo(mov.UP);
- elseif (mov.getY()>y)
- then
- mov.pointTo(mov.DOWN);
- end
- while(mov.getY()~=y)
- do
- mov.f(true);
- end
- --X pos
- if (mov.getX()<x)
- then
- mov.pointTo(mov.RIGHT);
- elseif (mov.getY()>y)
- then
- mov.pointTo(mov.LEFT);
- end
- while(mov.getX()~=x)
- do
- mov.f(true);
- end
- --Z pos
- while(mov.getZ()~=z)
- do
- if (mov.getZ()<z)
- then
- mov.u(true);
- elseif (mov.getZ()>z)
- then
- mov.d(true);
- end
- end
- mov.pointTo(dir);
- end
- local function quarry() --Main function
- local block, _;
- mov.f();
- --Columns
- for x=1, width
- do
- --Rows
- for y=1, height, 2
- do
- _, block=turtle.inspectDown();
- --Depth
- while (block.name~="minecraft:bedrock")
- do
- mov.d(true);
- if (y<height)
- then
- turtle.dig();
- end
- local bool, ev=coroutine.resume(checkThread);
- if (bool)
- then
- print(ev);
- end
- _, block=turtle.inspectDown();
- end
- --Bedrock Reached
- while (mov.getZ()<0)
- do
- mov.u(true);
- end
- --Top Reached
- --Moving forward
- for i=1, 2
- do
- if (mov.getY()<height-1)
- then
- mov.f(true);
- end
- end
- end
- while (mov.getY()>1)
- do
- mov.b();
- end
- --Back to Y=1
- mov.r();
- mov.f(true);
- mov.l();
- --Next column
- end
- goHome();
- end
- --Main code
- width=tonumber(args[1]);
- height=tonumber(args[2]);
- if (fs.exists("quarry.config"))
- then
- local configFile=fs.open("quarry.config", "r");
- config=textutils.unserialize(configFile.readAll());
- else
- local configFile=fs.open("quarry.config", "w");
- config=
- {
- enderChest=true;
- returnHome=true;
- net=false;
- placeTorches=false;
- buildLadder=false;
- };
- configFile.write(textutils.serialize(config));
- --TODO: Configuration program
- end
- os.loadAPI("serpensAPI/mov");
- mov.setPos(0, 0, 0);
- mov.setDir(1);
- mov.setWaitTime(0);
- local function test()
- while (true)
- do
- --[[for i=1, 15
- do
- if (turtle.getItemCount(i)==0)
- then
- coroutine.yield(false);
- end
- end
- coroutine.yield(true, "full");]]
- print(textutils.serialize(turtle.getItemDetail()));
- end
- end
- checkThread=coroutine.create(test);
- coroutine.resume(checkThread);
- quarry();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement