Ability to tether objects
This allows a user to get something, but if they leave an area, they automatically put it back.
This commit is contained in:
parent
9d7ff34566
commit
cff8a5176d
2 changed files with 23 additions and 2 deletions
|
|
@ -15,6 +15,8 @@ from utils.word_list import Token, routput
|
|||
from .objects import Object
|
||||
from .tutorial import TutorBird, TutorialState
|
||||
|
||||
from re import match
|
||||
|
||||
INTRO = """
|
||||
As the surrounding mists dissipate, you find yourself in an ancient, halcyon forest dripping with moss. You see an envelope of parchment wedged under a scaly protrusion of bark...inside, a letter in familiar penmanship, personally addressed to you, which you pick up.
|
||||
|
||||
|
|
@ -93,7 +95,7 @@ class Character(Object, DefaultCharacter):
|
|||
thing.move_to(self, quiet=True, use_destination=True)
|
||||
return
|
||||
|
||||
self.msg(f"{victim.key} doesn't have a {to_take}.")
|
||||
self.msg(f"{victim.key} doesn't have a {to_take} you can take.")
|
||||
else:
|
||||
self.msg(f"You don't see {from_whom}.")
|
||||
|
||||
|
|
@ -107,6 +109,25 @@ class Character(Object, DefaultCharacter):
|
|||
if self.db.is_sitting:
|
||||
self.msg("You stand up first...")
|
||||
self.db.is_sitting = False;
|
||||
|
||||
# @lock thing = tethered:id(#19)
|
||||
# @set thing/tethered_msg = "Let's put that back"
|
||||
for thing in self.contents:
|
||||
to = thing.locks.get('tethered')
|
||||
if to:
|
||||
m = match(r".*:id\(#?(.*)\)", to)
|
||||
if m:
|
||||
id_num = m.group(1)
|
||||
dest = self.global_search(f"#{id_num}")
|
||||
msg = thing.db.tethered_msg
|
||||
if dest and msg:
|
||||
thing.location = dest
|
||||
self.msg(msg)
|
||||
else:
|
||||
print(f"Found tethered, {thing} to #{id_num}, but dest is {dest} and msg is '{msg}'. Set both.")
|
||||
else:
|
||||
print(f"Found tethered, {thing} to #{to}, but that needs to be 'tethered:id(num) where num is the ID# of an object/place.")
|
||||
|
||||
return super().at_pre_move(destination)
|
||||
|
||||
def at_pre_say(self, message, **kwargs):
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ class Knocker(Object):
|
|||
# Let's see if a keyword gives a good response:
|
||||
for idx, [regex, responses] in enumerate(self.all_responses):
|
||||
full_regex = r".*" + regex + r".*"
|
||||
if re.match(full_regex, message):
|
||||
if re.match(full_regex, message, re.IGNORECASE):
|
||||
# The first match is the password, so we set a tag on
|
||||
# the character, so that they can go through the door:
|
||||
if idx == 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue