Advertisement
Kovitikus

Untitled

Jul 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. from evennia import create_object
  2.    
  3. class CmdCreateNPC(Command):
  4.     """
  5.    create a new npc
  6.  
  7.    Usage:
  8.        +createNPC <name>
  9.  
  10.    Creates a new, named NPC. The NPC will start with a Power of 1.
  11.    """
  12.     key = "+createnpc"
  13.     aliases = ["+createNPC"]
  14.     locks = "call:not perm(nonpcs)"
  15.     help_category = "mush"
  16.    
  17.     def func(self):
  18.         "creates the object and names it"
  19.         caller = self.caller
  20.         if not self.args:
  21.             caller.msg("Usage: +createNPC <name>")
  22.             return
  23.         if not caller.location:
  24.             # may not create npc when OOC
  25.             caller.msg("You must have a location to create an npc.")
  26.             return
  27.         # make name always start with capital letter
  28.         name = self.args.strip().capitalize()
  29.         # create npc in caller's location
  30.         npc = create_object("characters.Character",
  31.                       key=name,
  32.                       location=caller.location,
  33.                       locks="edit:id(%i) and perm(Builders);call:false()" % caller.id)
  34.         # announce
  35.         message = "%s created the NPC '%s'."
  36.         caller.msg(message % ("You", name))
  37.         caller.location.msg_contents(message % (caller.key, name),
  38.                                                 exclude=caller)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement