Triggers now work with |p and {0} for a target.

Fixed some bugs, including the trailing period when looking at something.
This commit is contained in:
Howard Abrams 2025-05-26 14:45:43 -07:00
parent 1cb69a9ab4
commit daace6e983
3 changed files with 58 additions and 21 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
from random import choice
from re import match from re import match
from evennia import CmdSet, create_script from evennia import CmdSet, create_script
@ -19,7 +20,9 @@ class CmdFly(Command):
Make sure you set the following properties, for instance: Make sure you set the following properties, for instance:
@set self/disappear_msg = "The wizard disappears in a puff of smoke." @set self/disappear_msg = "The wizard disappears in a puff of smoke."
@set self/reappear_msg = "A plume of <<white ^ light blue ^ gray ^ >> smoke appears... ;; When the smoke clears, a wizard <<emerges ^ materializes>>." @set self/reappear_msg = "A plume of <<white ^ light blue ^ gray ^ >>
smoke appears... ;; When the smoke clears, a
wizard <<emerges ^ materializes>>."
@set self/appear_delay = 3 @set self/appear_delay = 3
The last setting is the number of seconds between message segments The last setting is the number of seconds between message segments
@ -30,6 +33,9 @@ class CmdFly(Command):
locks = "cmd:holds()" locks = "cmd:holds()"
def func(self): def func(self):
"""
Call the 'do_fly' method on the caller.
"""
self.caller.do_fly(self.args.strip()) self.caller.do_fly(self.args.strip())
@ -93,12 +99,13 @@ class CmdGM(MuxCommand):
me = self.caller me = self.caller
msg = routput(self.args)
for o in send_to: for o in send_to:
if o.is_typeclass('typeclasses.rooms.Room'): if o.is_typeclass('typeclasses.rooms.Room'):
chars = o.contents_get(None, 'character') chars = o.contents_get(None, 'character')
send_emote(me, chars, self.args, 'say', None) send_emote(me, chars, msg, 'say', None)
elif o.is_typeclass('typeclasses.characters.Character'): elif o.is_typeclass('typeclasses.characters.Character'):
o.msg(self.args) o.msg(msg)
class CmdSpell(Command): class CmdSpell(Command):
@ -211,7 +218,7 @@ class CmdGMTrigger(Command):
if not self.name: if not self.name:
npc.msg("What event do you want to trigger?") npc.msg("What event do you want to trigger?")
for name,details in triggers.items(): for name, details in triggers.items():
npc.msg(f" - {name} : {details['desc']}") npc.msg(f" - {name} : {details['desc']}")
return return
@ -231,14 +238,21 @@ class CmdGMTrigger(Command):
element goes to 'dests' and the second goes to the room element goes to 'dests' and the second goes to the room
(based on the caller's location). (based on the caller's location).
""" """
if len(self.send_to) > 0:
target = self.send_to[0]
else:
target = choice(self.caller.characters_here())
name = target.db._sdesc or target.key or ""
for idx, event in enumerate(events): for idx, event in enumerate(events):
if isinstance(event, str): if isinstance(event, str):
msg = target.gendered_text(routput(event, name))
delay(time_delay * idx, delay(time_delay * idx,
self.caller.location.msg_contents, self.caller.location.msg_contents,
"\n" + routput(event)) "\n" + msg)
else: else:
char = event[0] char = target.gendered_text(routput(event[0], name))
room = event[1] room = target.gendered_text(routput(event[1], name))
if room: if room:
delay(time_delay * idx, delay(time_delay * idx,

View file

@ -211,18 +211,18 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
key="post_desc") or "" key="post_desc") or ""
reg_desc = super().return_appearance(looker) reg_desc = super().return_appearance(looker)
pronoun = self.pronoun_subjective(True) # pronoun = self.pronoun_subjective(True)
return self.gendered_text(pre_desc + \ return self.gendered_text(pre_desc +
reg_desc.replace('|wYou see:|n', reg_desc.replace('|wYou see:|n',
'|S has') + \ '|S has') +
post_desc + '.') post_desc)
def at_pre_move(self, destination, *args, **kwargs): def at_pre_move(self, destination, *args, **kwargs):
""" """
Called by self.move_to when trying to move somewhere. If this returns Called by self.move_to when trying to move somewhere. If this returns
False, the move is immediately canceled. False, the move is immediately canceled.
""" """
self.db.tutorstate = self.db.tutorstate | TutorialState.MOVE.value self.db.tutorstate = (self.db.tutorstate or 0) | TutorialState.MOVE.value
if self.db.is_sitting: if self.db.is_sitting:
self.msg("You stand up first...") self.msg("You stand up first...")
@ -250,7 +250,7 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
def at_pre_say(self, message, **kwargs): def at_pre_say(self, message, **kwargs):
"While we could/should do 'at_say', this should be easier." "While we could/should do 'at_say', this should be easier."
self.db.tutorstate = self.db.tutorstate | TutorialState.SAY.value self.db.tutorstate = (self.db.tutorstate or 0) | TutorialState.SAY.value
return super().at_pre_say(message) return super().at_pre_say(message)
def at_look(self, target, **kwargs): def at_look(self, target, **kwargs):
@ -278,9 +278,9 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
self.tags.add(hidden_tag) self.tags.add(hidden_tag)
if target.is_typeclass("typeclasses.rooms.Room"): if target.is_typeclass("typeclasses.rooms.Room"):
self.db.tutorstate = self.db.tutorstate | TutorialState.LOOK.value self.db.tutorstate = (self.db.tutorstate or 0) | TutorialState.LOOK.value
else: else:
self.db.tutorstate = self.db.tutorstate | TutorialState.LOOKAT.value self.db.tutorstate = (self.db.tutorstate or 0) | TutorialState.LOOKAT.value
# Regardless of what happened before, we return the normal # Regardless of what happened before, we return the normal
# function call. # function call.
@ -329,6 +329,15 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
self.db.reappear_msg.split(';;'), self.db.reappear_msg.split(';;'),
self.db.appear_delay or 2) self.db.appear_delay or 2)
def characters_here(self):
"""
Return a list of characters in the current location.
"""
return [char for char in
self.search("", typeclass="typeclasses.characters.Character",
location=self.location, quiet=True)
if char != self]
# Hooks to the puppets: # Hooks to the puppets:
def puppets_here(self): def puppets_here(self):

View file

@ -153,7 +153,7 @@ py bt = self.search('Bartender'); bt.db.gender = 'male'; bt.db._sdesc = 'blonde
# [[file:../../../projects/mud-rpg.org::*Or a Mushroom Bartender][Or a Mushroom Bartender:4]] # [[file:../../../projects/mud-rpg.org::*Or a Mushroom Bartender][Or a Mushroom Bartender:4]]
@detail mushroom;mushroom man = A stubby mushroom with an enormous red cap and a friendly looking face. Amazing how he can balance cocktails on its head. @detail mushroom person;mushroom man = A stubby mushroom with an enormous red cap and a friendly looking face. Amazing how he can balance cocktails on its head.
# Or a Mushroom Bartender:4 ends here # Or a Mushroom Bartender:4 ends here
# Pixie Quartet # Pixie Quartet
@ -177,14 +177,27 @@ py bt = self.search('pixies'); bt.db.pose_default = 'playing music atop a giant
@desc pixies = Atop a giant fieldcap mushroom, a quartet of pixies playing the strangest instruments you've never seen, fill the room with music. @desc pixies = Atop a giant fieldcap mushroom, a quartet of pixies playing the strangest instruments you've never seen, fill the room with music.
# Pixie Quartet:3 ends here # Pixie Quartet:3 ends here
# [[file:../../../projects/mud-rpg.org::*Pixie Quartet][Pixie Quartet:4]]
@detail mushroom = A giant, beige-colored mushroom grows on the side of this room providing a perfect stage for the pixie musicians.
# Pixie Quartet:4 ends here
# And give him the powers he deserves: # And give him the powers he deserves:
# [[file:../../../projects/mud-rpg.org::*Pixie Quartet][Pixie Quartet:4]] # [[file:../../../projects/mud-rpg.org::*Pixie Quartet][Pixie Quartet:5]]
@perm pixies = Admin @perm pixies = Admin
# Pixie Quartet:4 ends here # Pixie Quartet:5 ends here
# And when Dabbler arrives …
# [[file:../../../projects/mud-rpg.org::*Pixie Quartet][Pixie Quartet:6]]
@set pixies/arrive:dabbler = "8 ;; gm The quartet on the mushroom start playing an << interesting ^ odd >> << composition ^ song ^ arrangment >>. ;; 20 ;; The pixie leader says, \"As you can tell, we're playing << a jazz standard ^ a jazz melody ^ something the Mudders call, jazz fusion >>. That's right, something we picked up from << our travels in ^ >> the Mud World."
# Pixie Quartet:6 ends here
# Awakened Shrub # Awakened Shrub
# Next great NPC will a cameo from the Awakened Shrub. # Next great NPC will a cameo from the Awakened Shrub.
@ -244,17 +257,18 @@ py bt = self.search('shrub'); bt.db.gender = 'neutral'; bt.db._sdesc = 'shrub';
# [[file:../../../projects/mud-rpg.org::*Dabbler][Dabbler:2]] # [[file:../../../projects/mud-rpg.org::*Dabbler][Dabbler:2]]
@set/character #34/triggers:session1 = { @set/character #34/triggers:session1 = {
"bubbles": {"desc": "Character blows bubbles", "bubbles": {"desc": "Character blows bubbles",
"timer": 10, "timer": 5,
"events": [ "events": [
"The old gnome hits his staff on the floor.",
("You notice bubbles coming out every time you open your mouth to speak.", ("You notice bubbles coming out every time you open your mouth to speak.",
"Every time |s speaks, you notice bubbles coming from the mouth of /target." "Every time |s speaks, you notice bubbles coming from the mouth of the {0}."
) )
] ]
}, },
"dark": {"desc": "Make the room go black", "dark": {"desc": "Make the room go black",
"timer": 5, "timer": 5,
"events": [ "events": [
"The /gnome slams his staff against the floor. The room goes completely dark.", "The old gnome slams his staff against the floor. The room goes completely dark.",
"The music stops.", "The music stops.",
"In the darkness, you see a pair of large red eyes, and a low gutteral growl.", "In the darkness, you see a pair of large red eyes, and a low gutteral growl.",
("You can't help it, but scream!", ("You can't help it, but scream!",