Fixed headers on contribs, they were still referring to the old base*.py -style files under gamesrc.

This commit is contained in:
Griatch 2012-04-01 22:23:47 +02:00
parent ad63abee39
commit ca32950d90
4 changed files with 159 additions and 147 deletions

View file

@ -14,15 +14,20 @@ while puppeting a Character already before.
Installation:
Import this module in game.gamesrc.basecmdset and
add the following line to the end of OOCCmdSet's at_cmdset_creation():
self.add(chargen.OOCCmdSetCharGen)
Read the instructions in game/gamesrc/commands/examples/cmdset.py in
order to create a new default cmdset module for Evennia to use (copy
the template up one level, and change the settings file's relevant
variables to point to the cmdsets inside). If you already have such
a module you should of course use that.
Next import this module in your custom cmdset module and add the
following line to the end of OOCCmdSet's at_cmdset_creation():
self.add(chargen.OOCCmdSetCharGen)
"""
from django.conf import settings
from django.conf import settings
from ev import Command, create_object, utils
from ev import default_cmds, db_objects
@ -58,45 +63,45 @@ class CmdOOCLook(default_cmds.CmdLook):
is that only the CmdCharacterCreate command adds this attribute,
and thus e.g. player #1 will not be listed (although it will work).
Existence in this list does not depend on puppeting rights though,
that is checked by the @ic command directly.
that is checked by the @ic command directly.
"""
# making sure caller is really a player
# making sure caller is really a player
self.character = None
if utils.inherits_from(self.caller, "src.objects.objects.Object"):
# An object of some type is calling. Convert to player.
#print self.caller, self.caller.__class__
self.character = self.caller
self.character = self.caller
if hasattr(self.caller, "player"):
self.caller = self.caller.player
if not self.character:
# ooc mode, we are players
if not self.character:
# ooc mode, we are players
avail_chars = self.caller.db._character_dbrefs
if self.args:
# Maybe the caller wants to look at a character
if not avail_chars:
if not avail_chars:
self.caller.msg("You have no characters to look at. Why not create one?")
return
return
objs = db_objects.get_objs_with_key_and_typeclass(self.args.strip(), CHARACTER_TYPECLASS)
objs = [obj for obj in objs if obj.id in avail_chars]
if not objs:
if not objs:
self.caller.msg("You cannot see this Character.")
return
return
self.caller.msg(objs[0].return_appearance(self.caller))
return
return
# not inspecting a character. Show the OOC info.
# not inspecting a character. Show the OOC info.
charobjs = []
charnames = []
if self.caller.db._character_dbrefs:
dbrefs = self.caller.db._character_dbrefs
dbrefs = self.caller.db._character_dbrefs
charobjs = [db_objects.get_id(dbref) for dbref in dbrefs]
charnames = [charobj.key for charobj in charobjs if charobj]
if charnames:
if charnames:
charlist = "The following Character(s) are available:\n\n"
charlist += "\n\r".join(["{w %s{n" % charname for charname in charnames])
charlist += "\n\r".join(["{w %s{n" % charname for charname in charnames])
charlist += "\n\n Use {w@ic <character name>{n to switch to that Character."
else:
charlist = "You have no Characters."
@ -112,7 +117,7 @@ class CmdOOCLook(default_cmds.CmdLook):
self.caller.msg(string)
else:
# not ooc mode - leave back to normal look
# not ooc mode - leave back to normal look
self.caller = self.character # we have to put this back for normal look to work.
super(CmdOOCLook, self).func()
@ -120,11 +125,11 @@ class CmdOOCCharacterCreate(Command):
"""
creates a character
Usage:
Usage:
create <character name>
This will create a new character, assuming
the given character name does not already exist.
the given character name does not already exist.
"""
key = "create"
@ -133,34 +138,34 @@ class CmdOOCCharacterCreate(Command):
def func(self):
"""
Tries to create the Character object. We also put an
attribute on ourselves to remember it.
attribute on ourselves to remember it.
"""
# making sure caller is really a player
# making sure caller is really a player
self.character = None
if utils.inherits_from(self.caller, "src.objects.objects.Object"):
# An object of some type is calling. Convert to player.
#print self.caller, self.caller.__class__
self.character = self.caller
self.character = self.caller
if hasattr(self.caller, "player"):
self.caller = self.caller.player
if not self.args:
self.caller.msg("Usage: create <character name>")
return
return
charname = self.args.strip()
old_char = db_objects.get_objs_with_key_and_typeclass(charname, CHARACTER_TYPECLASS)
if old_char:
self.caller.msg("Character {c%s{n already exists." % charname)
return
return
# create the character
new_character = create_object(CHARACTER_TYPECLASS, key=charname)
if not new_character:
self.caller.msg("{rThe Character couldn't be created. This is a bug. Please contact an admin.")
return
return
# make sure to lock the character to only be puppeted by this player
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
(new_character.id, self.caller.id))
# save dbref
@ -171,15 +176,14 @@ class CmdOOCCharacterCreate(Command):
avail_chars = [new_character.id]
self.caller.db._character_dbrefs = avail_chars
self.caller.msg("{gThe Character {c%s{g was successfully created!" % charname)
self.caller.msg("{gThe Character {c%s{g was successfully created!" % charname)
class OOCCmdSetCharGen(default_cmds.OOCCmdSet):
"""
Extends the default OOC cmdset.
"""
"""
def at_cmdset_creation(self):
"Install everything from the default set, then overload"
#super(OOCCmdSetCharGen, self).at_cmdset_creation()
self.add(CmdOOCLook())
self.add(CmdOOCCharacterCreate())