Fix mining script
This commit is contained in:
parent
e76b849f93
commit
61677086e0
@ -1,7 +1,8 @@
|
||||
compareSlotMax = 4 -- all slots up to this one are used for comparing, order the blocks in decreasing probability
|
||||
compareSlotMax = 1 -- all slots up to this one are used for comparing, order the blocks in decreasing probability
|
||||
|
||||
xRelPos = 0 -- "positive = forward"
|
||||
yRelPos = 0 -- "positive = right"
|
||||
zRelPos = 0 -- "positive = upwards"
|
||||
|
||||
facing = {
|
||||
x = 1,
|
||||
@ -29,6 +30,21 @@ function forward()
|
||||
end
|
||||
end
|
||||
|
||||
function upwards()
|
||||
if turtle.up() then
|
||||
zRelPos = zRelPos + 1
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function downwards()
|
||||
if turtle.down() then
|
||||
zRelPos = zRelPos - 1
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
||||
function turnRight()
|
||||
turtle.turnRight()
|
||||
if facing.x == 1 and facing.y == 0 then -- facing forward
|
||||
@ -110,16 +126,15 @@ function moveTo(x, y)
|
||||
end
|
||||
|
||||
function blockIsWorth()
|
||||
return true
|
||||
|
||||
--[[for i = 1, compareSlotMax do
|
||||
for i = 1, compareSlotMax do
|
||||
turtle.select(i)
|
||||
if turtle.compare() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true]]
|
||||
return true
|
||||
end
|
||||
|
||||
function checkForItems(z)
|
||||
@ -163,7 +178,7 @@ function digHole()
|
||||
|
||||
-- go down
|
||||
turtle.digDown()
|
||||
while turtle.down() do
|
||||
while downwards() do
|
||||
z = z + 1
|
||||
checkForItems(z)
|
||||
turtle.digDown()
|
||||
@ -172,12 +187,11 @@ function digHole()
|
||||
-- go back up
|
||||
-- look at the remaining direction (-1, 0) and check blocks
|
||||
faceTo(-1, 0)
|
||||
while z > 0 do
|
||||
while zRelPos < 0 do
|
||||
if blockIsWorth() then
|
||||
turtle.dig()
|
||||
end
|
||||
turtle.up()
|
||||
z = z - 1
|
||||
upwards()
|
||||
end
|
||||
end
|
||||
|
||||
@ -188,7 +202,7 @@ function returnItems()
|
||||
faceTo(-1, 0)
|
||||
|
||||
-- already facing right direction, put items
|
||||
for slot = compareSlotMax + 1, fuelSlot - 1 do
|
||||
for slot = compareSlotMax + 1, 16 do
|
||||
turtle.select(slot)
|
||||
turtle.drop()
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user