Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = { ... }
- if #tArgs ~= 1 then
- print("Usage: botania <type>");
- print("<type> is one of: wood, stone");
- return;
- end
- pos = 1;
- runMe = 1;
- empty = 0;
- napTime = 10;
- waitTime = 2;
- findType = "";
- output = "";
- function nextPos()
- pos = pos + 1;
- if pos > 16 then
- pos = 1;
- end
- end
- function findBlock(findName)
- local lpos = pos;
- local tryNext = 0;
- turtle.select(lpos);
- if turtle.getItemCount(lpos) > 0 then
- local itemData = turtle.getItemDetail();
- --print("Slot "..lpos..": "..itemData.name);
- if itemData.name == findName then
- empty = 0;
- return true;
- else
- tryNext = 1;
- end
- else
- if empty == 16 then
- return false;
- else
- tryNext = 1;
- end
- end
- if tryNext then
- tryNext = 0;
- empty = empty + 1;
- nextPos();
- return findBlock(findName);
- end
- end
- function placeBlock(placeName)
- if findBlock(placeName) == false then
- return false;
- end
- local count = turtle.getItemCount();
- while count > 0 do
- if turtle.placeDown() then
- return true;
- else
- sleep(waitTime);
- end
- if findBlock(placeName) == false then
- return false;
- end
- count = turtle.getItemCount();
- end
- end
- function getTypeName(shortName)
- local types = {
- ["wood"] = "minecraft:log",
- ["stone"] = "minecraft:stone"
- }
- if types[shortName] then
- if shortName == "wood" then
- output = "Botania:livingwood";
- else
- output = "Botania:livingrock";
- end
- return types[shortName];
- else
- return false;
- end
- end
- function stopMe()
- runMe = 0;
- end
- --Main Loop Below
- local typeName = getTypeName(tArgs[1]);
- if typeName == false then
- return;
- end
- while runMe == 1 do
- if placeBlock(typeName) then
- while turtle.detectDown() do
- sleep(napTime);
- local success, data = turtle.inspectDown();
- if success then
- if data.name == output then
- turtle.digDown();
- end
- end
- end
- else
- print("Sleeping for "..napTime.." seconds.");
- empty = 0;
- sleep(napTime);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement