Compare commits
3 Commits
477007bc59
...
cfb3074158
Author | SHA1 | Date | |
---|---|---|---|
|
cfb3074158 | ||
|
e84d807957 | ||
|
035ab99fcc |
@ -14,8 +14,10 @@ def unpairZ(z):
|
||||
|
||||
lookup = [-10, 4, 1, 3, 0, 2]
|
||||
def isDiggingSpot(x, y):
|
||||
val = lookup[(y % 5) + 1]
|
||||
return (x % 5) == val
|
||||
x, y = int(x), int(y)
|
||||
val = lookup[(((y % 5)+5)%5) + 1]
|
||||
out = ((x % 5)+ 5) % 5 == val
|
||||
return out
|
||||
|
||||
global offset
|
||||
offset = 10
|
||||
@ -31,3 +33,32 @@ def ithSpot(i):
|
||||
i = i - 1
|
||||
j = j + 1
|
||||
|
||||
def adjustToQuadrant(i, x, z):
|
||||
if i % 4 == 0:
|
||||
return x, z
|
||||
elif i % 4 == 1:
|
||||
return -z-1, x
|
||||
elif i % 4 == 2:
|
||||
return z, -x-1
|
||||
elif i % 4 == 3:
|
||||
return -z-1, -x-1
|
||||
|
||||
def iTo2Dcoords(j):
|
||||
i = j // 4
|
||||
quadrantI = j % 4 # 0-3 quadrant
|
||||
counter = 0 # number of digging spots found
|
||||
j = 0 # enumerate 2D plane
|
||||
while True:
|
||||
x, z = int(unpairX(j)), int(unpairZ(j)) # coords in first quadrant
|
||||
x, z = adjustToQuadrant(quadrantI, x, z) # map coords correctly into other quadrants
|
||||
if isDiggingSpot(x, z):
|
||||
if counter == i:
|
||||
return (x,z)
|
||||
break
|
||||
counter += 1
|
||||
j += 1
|
||||
|
||||
print(iTo2Dcoords(3))
|
||||
|
||||
# for i in range(10):
|
||||
# print(iTo2Dcoords(i))
|
||||
|
@ -106,6 +106,13 @@ function moveSafe(moveAction, inspectAction, digAction)
|
||||
if block["name"]:lower():find("turtle") then
|
||||
-- turtle in front of me. lets wait for it to move
|
||||
sleep(0.6)
|
||||
elseif block["name"]:lower().find("water") or block["name"]:lower().find("lava") then
|
||||
if moveAction() then
|
||||
break
|
||||
else
|
||||
digAction()
|
||||
updateState({ state = "I am stuck trying to walk into a liquid." })
|
||||
end
|
||||
else
|
||||
digAction()
|
||||
end
|
||||
@ -414,13 +421,17 @@ function drawStatus()
|
||||
print()
|
||||
print(" \""..turtlestate["name"].."\"")
|
||||
print()
|
||||
print()
|
||||
if turtlestate["job"] then
|
||||
print("Current job: "..tostring(turtlestate["job"]))
|
||||
else
|
||||
print("Current job: ")
|
||||
end
|
||||
print()
|
||||
if turtle["startfuel"] then
|
||||
print("Starting Fuel: "..tostring(turtlestate["startfuel"]))
|
||||
else
|
||||
print("Starting Fuel: ")
|
||||
end
|
||||
if turtlestate["job"] then
|
||||
print("Recent fuel usage: "..tostring(turtlestate["fuel"]))
|
||||
else
|
||||
@ -674,7 +685,7 @@ function turtleAI2()
|
||||
local job = enqueueForJob2()
|
||||
turtlestate["job"] = job
|
||||
doRefuel2()
|
||||
startfuel = turtle.getFuelLevel()
|
||||
turtlestate["startfuel"] = turtle.getFuelLevel()
|
||||
goToJob2(job)
|
||||
digShaft()
|
||||
goToUnloading()
|
||||
|
Loading…
Reference in New Issue
Block a user