Created
August 30, 2017 08:11
-
-
Save bobbzorzen/d5e0d59c5359431bb2c5030bc2387532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tArgs = {...} | |
local rows = tonumber(tArgs[1]) | |
local columns = tonumber(tArgs[2]) | |
local enderchest_index = tonumber(tArgs[3] or -1) | |
y = 0 | |
print(string.format("Filling %s by %s area with refill chest on index %s", rows, columns, enderchest_index)) | |
function refillFromEnderchest() | |
turtle.select(enderchest_index) | |
turtle.placeUp() | |
for i = 1,16 do | |
if i ~= enderchest_index then | |
turtle.select(i) | |
turtle.suckUp() | |
end | |
end | |
print("Selecting ".. enderchest_index) | |
turtle.select(enderchest_index) | |
print("Digging up") | |
turtle.digUp() | |
end | |
function fillDown() | |
for i = 1,16 do | |
if i ~= enderchest_index then | |
print(string.format("%s ~= %s", i, enderchest_index)) | |
turtle.select(i) | |
if turtle.getItemCount(i) > 0 then | |
turtle.placeDown() | |
print("placing down item on index: "..i.." - " .. enderchest_index) | |
return true | |
end | |
end | |
end | |
if enderchest_index ~= -1 then | |
refillFromEnderchest() | |
fillDown() | |
end | |
return false | |
end | |
function switchColumn(columnIndex) | |
if columnIndex%2 ~= 0 then | |
turtle.turnRight() | |
turtle.forward() | |
turtle.turnRight() | |
else | |
turtle.turnLeft() | |
turtle.forward() | |
turtle.turnLeft() | |
end | |
end | |
for j = 1,rows do | |
for i = 1,columns do | |
while turtle.down() do | |
y = y-1 | |
end | |
while y<0 do | |
y = y+1 | |
turtle.up() | |
fillDown() | |
end | |
if tonumber(i) < tonumber(columns) then | |
turtle.forward() | |
end | |
end | |
if tonumber(j) < tonumber(rows) then | |
switchColumn(j) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment