Add sand safety inspection command
This commit is contained in:
1 parent
c3a045d17a
commit
142381d40f
5 files changed
+103
-51
No files matched your search
@@ -126,6 +126,21 @@ class Commands:
|
||||
if command == 'nosquarebrackets':
|
||||
reply = 'don\'t literally put the [ ]'
|
||||
|
||||
## !safesand x y z - report whether a sand block is safe to dig
|
||||
if command == 'safesand':
|
||||
coordinates = re.split(r'\s*,\s*|\s+', data.strip())
|
||||
if (len(coordinates) != 3 or
|
||||
any(not re.fullmatch(r'-?\d+', value)
|
||||
for value in coordinates)):
|
||||
reply = 'no: use !safesand x y z (spaces or commas)'
|
||||
else:
|
||||
position = tuple(int(value) for value in coordinates)
|
||||
safe, reason = self.g.world.sand_safety(position)
|
||||
if safe and not self.g.world.work_position_allowed(position):
|
||||
safe = False
|
||||
reason = 'outside active work-sign boundaries'
|
||||
reply = '{}: {}'.format('yes' if safe else 'no', reason)
|
||||
|
||||
## !pos - replies with position and dimension
|
||||
if command == 'pos':
|
||||
reply = str(utils.pint(self.g.pos))[1:-1] + ', ' + self.g.dimension
|
||||
|
||||
Reference in new issue
Block a user