Find trees using new 3D search
This commit is contained in:
@@ -140,18 +140,20 @@ class GatherWoodStates:
|
||||
w = self.g.world
|
||||
p = utils.pint(self.g.pos)
|
||||
|
||||
trees = w.find_trees(p, 100)
|
||||
print('Found trees:', trees)
|
||||
|
||||
try:
|
||||
while trees[0] in self.bad_trees:
|
||||
trees.pop(0)
|
||||
self.tree = trees[0]
|
||||
except IndexError:
|
||||
print('No good tress left, aborting.')
|
||||
for tree in w.find_trees(p, 100):
|
||||
print('Found tree:', tree)
|
||||
if tree not in self.bad_trees:
|
||||
break
|
||||
else: # for
|
||||
print('No good trees left, aborting.')
|
||||
self.state = self.cleanup
|
||||
return
|
||||
|
||||
self.tree = tree
|
||||
self.state = self.find_openings
|
||||
|
||||
def find_openings(self):
|
||||
w = self.g.world
|
||||
self.openings = w.find_tree_openings(self.tree)
|
||||
self.state = self.choose_opening
|
||||
|
||||
@@ -251,7 +253,15 @@ class GatherWoodStates:
|
||||
else:
|
||||
self.g.chopped_tree = True
|
||||
self.good_trees.append(self.tree)
|
||||
self.state = self.check_pos
|
||||
|
||||
def check_pos(self):
|
||||
# make sure we are at base of trunk
|
||||
# doesn't always happen, for some reason
|
||||
if utils.pint(self.g.pos) == self.tree:
|
||||
self.state = self.cleanup
|
||||
else:
|
||||
self.state = self.find_openings
|
||||
|
||||
def cleanup(self):
|
||||
self.g.look_at = None
|
||||
@@ -820,7 +830,7 @@ class GrabSaplingStates:
|
||||
saplings = w.find_objects(items.SAPLING_IDS)
|
||||
|
||||
if not saplings:
|
||||
print('No saplings objects found, aborting')
|
||||
print('No sapling objects found, aborting')
|
||||
self.state = self.cleanup
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user