Make sign policy distance unlimited
This commit is contained in:
1 parent
5c6c08e3c0
commit
315bc212dc
2 files changed
+19
-2
No files matched your search
+3
-2
@@ -67,7 +67,8 @@ class World:
|
|||||||
if hasattr(chunks, 'block_entities_snapshot') else
|
if hasattr(chunks, 'block_entities_snapshot') else
|
||||||
dict(chunks.block_entities))
|
dict(chunks.block_entities))
|
||||||
for position, entity in entities.items():
|
for position, entity in entities.items():
|
||||||
if utils.phyp(center, position) > distance:
|
if (distance is not None and
|
||||||
|
utils.phyp(center, position) > distance):
|
||||||
continue
|
continue
|
||||||
get_block_at = getattr(self.g.chunks, 'get_block_at', None)
|
get_block_at = getattr(self.g.chunks, 'get_block_at', None)
|
||||||
if callable(get_block_at):
|
if callable(get_block_at):
|
||||||
@@ -313,7 +314,7 @@ class World:
|
|||||||
result.sort(key=lambda chest: utils.phyp(center, chest['position']))
|
result.sort(key=lambda chest: utils.phyp(center, chest['position']))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def sign_policies(self, bot_name, distance=64):
|
def sign_policies(self, bot_name, distance=None):
|
||||||
"""Parse sign policies addressed to this bot or its numbered group."""
|
"""Parse sign policies addressed to this bot or its numbered group."""
|
||||||
bot_name = str(bot_name).casefold()
|
bot_name = str(bot_name).casefold()
|
||||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||||
|
|||||||
@@ -107,6 +107,22 @@ class SignReadingTests(unittest.TestCase):
|
|||||||
individual_world.sign_policies('mosfet2')], ['circle'])
|
individual_world.sign_policies('mosfet2')], ['circle'])
|
||||||
self.assertEqual(individual_world.sign_policies('mosfet1'), [])
|
self.assertEqual(individual_world.sign_policies('mosfet1'), [])
|
||||||
|
|
||||||
|
def test_sign_policies_read_any_distance_within_loaded_signs(self):
|
||||||
|
position = (100, 64, 0)
|
||||||
|
chunks = Munch(block_entities={position: {
|
||||||
|
'data': {'front_text': {'messages': [
|
||||||
|
'mosfet2', 'stay within 35 square', '', '',
|
||||||
|
]}},
|
||||||
|
}})
|
||||||
|
world = World(Munch(chunks=chunks, pos=(0, 64, 0)))
|
||||||
|
|
||||||
|
policies = world.sign_policies('mosfet2')
|
||||||
|
|
||||||
|
self.assertEqual(policies, [{
|
||||||
|
'position': position, 'distance': 35,
|
||||||
|
'shape': 'square', 'side': 'front',
|
||||||
|
}])
|
||||||
|
|
||||||
def test_nearest_sign_policy_overrides_farther_matching_sign(self):
|
def test_nearest_sign_policy_overrides_farther_matching_sign(self):
|
||||||
chunks = Munch(block_entities={
|
chunks = Munch(block_entities={
|
||||||
(-138, 71, -268): {'data': {'front_text': {'messages': [
|
(-138, 71, -268): {'data': {'front_text': {'messages': [
|
||||||
|
|||||||
Reference in new issue
Block a user