Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from evennia import create_object
- class CmdCreateNPC(Command):
- """
- create a new npc
- Usage:
- +createNPC <name>
- Creates a new, named NPC. The NPC will start with a Power of 1.
- """
- key = "+createnpc"
- aliases = ["+createNPC"]
- locks = "call:not perm(nonpcs)"
- help_category = "mush"
- def func(self):
- "creates the object and names it"
- caller = self.caller
- if not self.args:
- caller.msg("Usage: +createNPC <name>")
- return
- if not caller.location:
- # may not create npc when OOC
- caller.msg("You must have a location to create an npc.")
- return
- # make name always start with capital letter
- name = self.args.strip().capitalize()
- # create npc in caller's location
- npc = create_object("characters.Character",
- key=name,
- location=caller.location,
- locks="edit:id(%i) and perm(Builders);call:false()" % caller.id)
- # announce
- message = "%s created the NPC '%s'."
- caller.msg(message % ("You", name))
- caller.location.msg_contents(message % (caller.key, name),
- exclude=caller)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement