# —————————————————————————–
# Function: cmd_sayto
# A derivative of Say that allows one to direct speech to a specific person.
#
# In-game usage:
# > sayto <person> <message>
def cmd_sayto(ch, cmd, arg):
# See if we can find the player
try:
tgt, mssg = parse_args(ch, True, cmd, arg, "ch.world.noself string")
except:
message(ch, None, None, None, False, "to_char", "What are you trying to say to someone, and to whom?")
return
do_sayto(ch, tgt, mssg)
# —————————————————————————–
# Function: do_sayto
# The actual heart of the targetted say code.
def do_sayto(ch, tgt, mssg):
if (mssg == ''):
ch.send("Say what?")
else:
mssg = comm.preprocess_msg(mssg)
teststr = mssg
period = re.compile( r"^(.+)\.$" )
question = re.compile( r"^(.+)\?$" )
exclamation = re.compile( r"^(.+)\!$" )
if (question.match( teststr )):
isQuestion = "yes"
isExclamation = "no"
else:
if (exclamation.match( teststr )):
isQuestion = "no"
isExclamation = "yes"
else:
isQuestion = "no"
isExclamation = "no"
if (isQuestion == "yes"):
# act is "ask"
act_3p = "asks"
act_1p = "ask"
elif (isExclamation == "yes"):
# act is "exclaim"
act_3p = "exclaims"
act_1p = "exclaim"
else:
# act is "say"
act_3p = "says"
act_1p = "say"
# Get names
cname = ch.name
tname = tgt.name
# Send the message
if (isQuestion == "yes"):
msg_3p = ("{C%s %s %s, \"%s\"{n" % (cname, act_3p, tname, mssg))
msg_2p = ("{C%s %s you, \"%s\"{n" % (cname, act_3p, mssg))
msg_1p = ("{CYou %s %s, \"%s\"{n" % (act_1p, tname, mssg))
else:
msg_3p = ("{C%s %s to %s, \"%s\"{n" % (cname, act_3p, tname, mssg))
msg_2p = ("{C%s %s to you, \"%s\"{n" % (cname, act_3p, mssg))
msg_1p = ("{CYou %s to %s, \"%s\"{n" % (act_1p, tname, mssg))
send_message(msg_1p, ch, msg_2p, tgt, msg_3p)
# Say hook
hooks.run("say", hooks.build_info("ch str", (ch, mssg)))
import auxiliary, storage
class AuxData:
def __init__(self, storage_set=None):
self.whatever = "whatever"
if storage_set is not None:
if storage_set.contains("whatever"):
self.whatever = storage_set.readString("whatever")
def copyTo(self, to):
to.whatever = self.whatever
def copy(self):
new = AuxData()
self.copyTo(new)
return new
def store(self):
storage_set = storage.StorageSet()
storage_set.storeString("whatever", self.whatever)
return storage_set
auxiliary.install("aux_data", AuxData, "character")
import mud, mudsys
def cmd_poke(ch, cmd, arg):
try:
tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
except:
return
mud.message(ch, tgt, None, None, True, "to_char", "You poke $N.")
mud.message(ch, tgt, None, None, True, "to_vict", "$n pokes you.")
mud.message(ch, tgt, None, None, True, "to_room", "$n pokes $N.")
tgt.act("say That smarts.")
mudsys.add_cmd("poke", None, cmd_poke, "player", False)