Canned Emotes!

View previous topic View next topic Go down

Canned Emotes!

Post by Creator on Sat Aug 29, 2015 11:40 am

Here's the template for writing new canned emotes. If you change the name, key, optional aliases, and messages and then post here, I can load your new ones into the game!

Code:
class CmdHighfiveEmote(Command):

    auto_help = False
    key = "highfive"
    aliases = "hi5, hif"
    locks = "cmd:all()"
    help_category = "Emotes"

    def parse(self):
        "Very trivial parser"
        self.target = self.args.strip()

    def func(self):
        "This actually does things"
        caller = self.caller
        if not self.target or self.target == "here":
            string = "%s thrusts a hand palm first into the air, highfiving nobody. What a loser." % caller.name
            caller.location.msg_contents(string, exclude=caller)
            caller.msg("You thrust your hand into the air, intending to meet somebody's palm with your own, only to realise nobody is there.")
        else:
            target = caller.search(self.target)
            if not target:
                # caller.search handles error messages
                return
            string = "%s eagerly thrusts an arm out palm first, highfiving you with enthusiasm." % caller.name
            target.msg(string)
            string = "You eagerly thrust an arm out palm first, highfiving %s with enthusiasm." % target.name
            caller.msg(string)
            string = "%s eagerly thrusts an arm out palm first, highfiving %s with enthusiasm." % (caller.name, target.name)          
            caller.location.msg_contents(string, exclude=[caller,target])

Note that the aliases line is optional, it allows several commands to execute the same code. Here's another example of one that uses gender pronouns, a bit more complex:

Code:
class CmdNoEmote(Command):

    auto_help = False
    key = "no"
    aliases = "shake"
    locks = "cmd:all()"
    help_category = "Emotes"

    def parse(self):
        "Very trivial parser"
        self.target = self.args.strip()

    def func(self):
        "This actually does things"
        caller = self.caller
        if not self.target or self.target == "here":
            string = "%s shakes %s head." % (caller.name, gender_check(caller, "his"))
            caller.location.msg_contents(string, exclude=caller)
            caller.msg("You shake your head.")
        else:
            target = caller.search(self.target)
            if not target:
                # caller.search handles error messages
                return
            string = "%s just shakes %s head at you." % (caller.name, gender_check(caller, "his"))
            target.msg(string)
            string = "You just shake your head at %s." % target.name
            caller.msg(string)
            string = "%s just shakes %s head at %s." % (caller.name, gender_check(caller, "his"), target.name)
            caller.location.msg_contents(string, exclude=[caller,target])

And, because it's been asked, here's the gender_check method for your reference:

Code:
def gender_check(checking, string):
   if string != "he" and string != "his" and string != "him" and string != "himself":
      return "call-gender-pronoun-error"
   else:
      if checking.db.gender:
         if checking.db.gender == "male":
            return string
         else:
            if string == "he":
               return "she"
            elif string == "his":
               return "her"
            elif string == "him":
               return "her"
            elif string == "himself":
               return "herself"
      else:
         if string == "he":
            return "it"
         elif string == "his":
            return "its"
         elif string == "him":
            return "it"
         elif string == "himself":
            return "itself"


Last edited by Admin on Sat Aug 29, 2015 12:56 pm; edited 1 time in total

Creator
Admin

Posts : 4
Join date : 2015-08-29

View user profile http://crestilan.forumotion.com

Back to top Go down

Re: Canned Emotes!

Post by Majurad on Sat Aug 29, 2015 12:54 pm

Code:
class CmdByeEmote(Command):

   auto_help = False
   key = "bye"
   aliases = "wave"
   locks = "cmd:all()"
   help_category = "Emotes"

   def parse(self):
       "Very trivial parser"
       self.target = self.args.strip()

   def func(self):
       "This actually does things"
       caller = self.caller
       if not self.target or self.target == "here":
           string = "%s waves goodbye." % (caller.name)
           caller.location.msg_contents(string, exclude=caller)
           caller.msg("You wave goodbye.")
       else:
           target = caller.search(self.target)
           if not target:
               # caller.search handles error messages
               return
           string = "%s looks at you as %s waves goodbye." % (caller.name, gender_check(caller, "he"))
           target.msg(string)
           string = "You look at %s and wave goodbye." % target.name
           caller.msg(string)
           string = "%s looks at %s as %s waves goodbye." % (caller.name, target.name, gender_check(caller, "he"))
           caller.location.msg_contents(string, exclude=[caller,target])


Last edited by Majurad on Sat Aug 29, 2015 12:56 pm; edited 1 time in total

Majurad

Posts : 4
Join date : 2015-08-29

View user profile

Back to top Go down

Re: Canned Emotes!

Post by Majurad on Sat Aug 29, 2015 12:55 pm

Code:
class CmdChinEmote(Command):

    auto_help = False
    key = "chin"
    aliases = ""
    locks = "cmd:all()"
    help_category = "Emotes"

    def parse(self):
        "Very trivial parser"
        self.target = self.args.strip()

    def func(self):
        "This actually does things"
        caller = self.caller
        if not self.target or self.target == "here":
            string = "%s rubs %s chin in deep thought." % (caller.name, gender_check(caller, "his"))
            caller.location.msg_contents(string, exclude=caller)
            caller.msg("You rub your chin in deep thought.")
        else:
            target = caller.search(self.target)
            if not target:
                # caller.search handles error messages
                return
            string = "%s looks at you and rubs %s chin in thought." % (caller.name, gender_check(caller, "his"))
            target.msg(string)
            string = "You look at %s and rub your chin." % target.name
            caller.msg(string)
            string = "%s looks at %s and rubs %s chin." % (caller.name, target.name, gender_check(caller, "his"))
            caller.location.msg_contents(string, exclude=[caller,target])

Majurad

Posts : 4
Join date : 2015-08-29

View user profile

Back to top Go down

Re: Canned Emotes!

Post by Majurad on Sun Aug 30, 2015 4:01 pm

Code:
class CmdAhEmote(Command):

    auto_help = False
    key = "ah"
    aliases =
    locks = "cmd:all()"
    help_category = "Emotes"

    def parse(self):
        "Very trivial parser"
        self.target = self.args.strip()

    def func(self):
        "This actually does things"
        caller = self.caller
        if not self.target or self.target == "here":
            string = "%s eyes light up as %s suddenly lets out an 'Ah'." % (caller.name, gender_check(caller, "he"))
            caller.location.msg_contents(string, exclude=caller)
            caller.msg("Your eyes light up as you let out an 'Ah'.")
        else:
            target = caller.search(self.target)
            if not target:
                # caller.search handles error messages
                return
            if target == caller:
                string = "Your eyes light up as you let out an 'Ah'."
                caller.msg(string)
                string = "%s eyes light up as %s suddenly lets out an 'Ah'." (caller.name, gender_check(caller, "he"))
                caller.location.msg_contents(string, exclude=caller)
            else:
                string = "%s looks towards you and lets out an 'Ah'." % caller.name
                target.msg(string)
                string = "You look at %s and let out an 'Ah'." % target.name
                caller.msg(string)
                string = "%s looks at %s and lets out an 'Ah'." % (caller.name, target.name)
                caller.location.msg_contents(string, exclude=[caller,target])

Majurad

Posts : 4
Join date : 2015-08-29

View user profile

Back to top Go down

Re: Canned Emotes!

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum