Fix bug when taking objects from non-characters
Not that you _can_, but it shouldn't give a stack trace.
This commit is contained in:
parent
583c94433a
commit
853b1c2504
2 changed files with 16 additions and 6 deletions
|
|
@ -407,7 +407,17 @@ class CmdTake(CmdGet, NumberedTargetCommand):
|
||||||
else:
|
else:
|
||||||
super().func() # Call the 'get' function instead.
|
super().func() # Call the 'get' function instead.
|
||||||
else:
|
else:
|
||||||
self.caller.do_take(self.lhs, self.rhs)
|
location = self.caller.search(self.rhs, quiet=True)
|
||||||
|
if len(location) == 0:
|
||||||
|
self.caller.msg(f"Can't take '{self.lhs}' from '{self.rhs}'.")
|
||||||
|
return
|
||||||
|
|
||||||
|
location = location[0]
|
||||||
|
if location.is_typeclass("typeclasses.rooms.Room"):
|
||||||
|
self.args = self.lhs
|
||||||
|
super().func() # Call the 'get' function instead.
|
||||||
|
return
|
||||||
|
self.caller.do_take(self.lhs, location)
|
||||||
|
|
||||||
|
|
||||||
class CmdDrink(Command):
|
class CmdDrink(Command):
|
||||||
|
|
|
||||||
|
|
@ -229,18 +229,18 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
|
||||||
def get_display_things(self, looker, *args, **kwargs):
|
def get_display_things(self, looker, *args, **kwargs):
|
||||||
return super().get_display_things(looker, pose=False)
|
return super().get_display_things(looker, pose=False)
|
||||||
|
|
||||||
def do_take(self, to_take, from_whom):
|
def do_take(self, to_take, victim):
|
||||||
"""
|
"""
|
||||||
A character has a _steal_command. What are the limitations?
|
A character has a _steal_command. What are the limitations?
|
||||||
"""
|
"""
|
||||||
victim = self.search(from_whom)
|
|
||||||
if victim:
|
if victim:
|
||||||
|
thing = None
|
||||||
|
if hasattr(victim, 'has') and callable(getattr(victim, 'has')):
|
||||||
thing = victim.has(to_take)
|
thing = victim.has(to_take)
|
||||||
if thing and thing.db.can_take:
|
if thing and thing.db.can_take:
|
||||||
self.msg(f"You take {thing.key} from {victim.key}.")
|
self.msg(f"You take {thing.key} from {victim.key}.")
|
||||||
thing.move_to(self, quiet=True, use_destination=True)
|
thing.move_to(self, quiet=True, use_destination=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.msg(f"{victim.key} doesn't have a {to_take} you can take.")
|
self.msg(f"{victim.key} doesn't have a {to_take} you can take.")
|
||||||
|
|
||||||
def pronoun_subjective(self, uppercase=False):
|
def pronoun_subjective(self, uppercase=False):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue