Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile("lib_turtle_0.2.3");
- dofile("lib_neko_0.1.1");
- local tunnelLen = 0;
- local depthLevel = 0;
- local negaAry = { 3, 4, 5, 6, 7 };
- local OTHER_FROM = 8;
- local OTHER_TO = 16;
- local function unloadBlocks()
- local tmpAry = {};
- for _, slotIdx in pairs(negaAry) do
- table.insert(tmpAry, { slotIndex = slotIdx, keepCnt = 1 });
- end
- for i = OTHER_FROM, OTHER_TO do
- table.insert(tmpAry, { slotIndex = i, keepCnt = 0 });
- end
- local primaryChest = true;
- for _, unloadInfo in pairs(tmpAry) do
- local idx = unloadInfo.slotIndex;
- local keepCnt = unloadInfo.keepCnt;
- turtle.select(idx);
- local failureCnt = 0;
- while true do
- turtle.drop(turtle.getItemCount(idx) - keepCnt);
- if keepCnt < turtle.getItemCount(idx) then
- failureCnt = failureCnt + 1;
- if 2 <= failureCnt then
- print("Since the contents of the chest are full,");
- print("blocks cannot be put in.");
- print("Please make sufficient free space.");
- print("Hit enter key when ready.");
- read();
- failureCnt = 0;
- end
- turtle.turnRight();
- turtle.turnRight();
- primaryChest = not primaryChest;
- else
- break;
- end
- end
- end
- if primaryChest then
- turtle.turnLeft();
- else
- turtle.turnRight();
- end
- end
- local function dropNegaBlocks()
- for _, slotIdx in pairs(negaAry) do
- turtle.select(slotIdx);
- for j = OTHER_FROM, OTHER_TO do
- if turtle.compareTo(j) then
- turtle.select(j);
- turtle.drop();
- turtle.select(slotIdx);
- end
- end
- end
- end
- local function myUserEvent(para1)
- if 0 == para1 then
- nekoNega(0, negaAry);
- elseif 1 == para1 then
- nekoNega(1, negaAry);
- elseif 2 == para1 then
- nekoNega(2, negaAry);
- elseif 3 == para1 then
- for _, slotIdx in pairs(negaAry) do
- if 2 <= turtle.getItemCount(slotIdx) then
- turtle.select(slotIdx);
- turtle.place();
- break;
- end
- end
- elseif 4 == para1 then
- if 0 == tunnelLen % 8 then
- local sel = -1;
- if 2 <= turtle.getItemCount(1) then
- sel = 1;
- elseif 2 <= turtle.getItemCount(2) then
- sel = 2;
- end
- if -1 ~= sel then
- turtle.select(sel);
- turtle.up();
- turtle.dig();
- turtle.down();
- turtle.placeUp();
- turtle.select(1);
- end
- end
- tunnelLen = tunnelLen + 1;
- if 0 == tunnelLen % 6 then
- dropNegaBlocks();
- end
- elseif 5 == para1 then
- tunnelLen = 0;
- elseif 6 == para1 then
- unloadBlocks();
- elseif 7 == para1 then
- dropNegaBlocks();
- end
- end
- userEventHandler = myUserEvent;
- print("slot1 : torch x 64");
- print("slot2 : torch x 64");
- print("slot3 : Stone x 1");
- print("slot4 : Dirt x 1");
- print("slot5 : Gravel x 1");
- print("slot6 : Obsidian x 1");
- print("slot7 : Cobblestone x 1");
- print("Hit enter key when ready.");
- read();
- log("-------------------------------");
- log("-- mining_0.1.1 start");
- log("-------------------------------");
- for depthLevel = 0, 31 do
- local msg = "depthLevel = " .. depthLevel .. " / fuelLevel = " .. turtle.getFuelLevel();
- print(msg);
- log(msg);
- doCommand(
- " e0e1f"
- .. "(e0e1 v2 lv1 rrv1 u v1 ll v1 r v0 df)3 e0 v2 l v7"
- .. "(e1fv2 lv1 rrv1 e0uv1 llv1 rv0d v4)" .. (depthLevel * 4 + 10)
- .. "(s1 ll e1fe0rr v3 uv3d)" .. (depthLevel * 4 + 10)
- .. "e0u e1 s1p1d rr v5"
- .. "s1 (e1fv2 lv1 rrv1 e0uv1 llv1 rv0d v4)" .. (depthLevel * 4 + 10)
- .. "(s1 ll e1f k1 e0rr v3 uv3d)" .. (depthLevel * 4 + 10)
- .. "r (e1f)" .. ((depthLevel + 1) * 4)
- .. "l v6"
- );
- if turtle.getFuelLevel() < 2000 then
- print("Keep fuelLevel over 2000.");
- print("Please refuel.");
- refuelPrompt(nil);
- end
- doCommand(
- " (e1f)" .. ((depthLevel + 1) * 4)
- );
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement