More whitespace cleanup.
This commit is contained in:
parent
c0322c9eae
commit
45c5be8468
43 changed files with 1116 additions and 1131 deletions
|
|
@ -3,16 +3,16 @@
|
|||
Template for Characters
|
||||
|
||||
Copy this module up one level and name it as you like, then
|
||||
use it as a template to create your own Character class.
|
||||
use it as a template to create your own Character class.
|
||||
|
||||
To make new logins default to creating characters
|
||||
To make new logins default to creating characters
|
||||
of your new type, change settings.BASE_CHARACTER_TYPECLASS to point to
|
||||
your new class, e.g.
|
||||
|
||||
settings.BASE_CHARACTER_TYPECLASS = "game.gamesrc.objects.mychar.MyChar"
|
||||
|
||||
Note that objects already created in the database will not notice
|
||||
this change, you have to convert them manually e.g. with the
|
||||
this change, you have to convert them manually e.g. with the
|
||||
@typeclass command.
|
||||
|
||||
"""
|
||||
|
|
@ -20,22 +20,21 @@ from ev import Character
|
|||
|
||||
class ExampleCharacter(Character):
|
||||
"""
|
||||
The Character is like any normal Object (see example/object.py for
|
||||
a list of properties and methods), except it actually implements
|
||||
some of its hook methods to do some work:
|
||||
|
||||
at_basetype_setup - always assigns the default_cmdset to this object type
|
||||
(important!)sets locks so character cannot be picked up
|
||||
The Character is like any normal Object (see example/object.py for
|
||||
a list of properties and methods), except it actually implements
|
||||
some of its hook methods to do some work:
|
||||
|
||||
at_basetype_setup - always assigns the default_cmdset to this object type
|
||||
(important!)sets locks so character cannot be picked up
|
||||
and its commands only be called by itself, not anyone else.
|
||||
(to change things, use at_object_creation() instead)
|
||||
at_after_move - launches the "look" command
|
||||
at_disconnect - stores the current location, so the "unconnected" character
|
||||
object does not need to stay on grid but can be given a
|
||||
None-location while offline.
|
||||
object does not need to stay on grid but can be given a
|
||||
None-location while offline.
|
||||
at_post_login - retrieves the character's old location and puts it back
|
||||
on the grid with a "charname has connected" message echoed
|
||||
to the room
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ your new class, e.g.
|
|||
settings.BASE_EXIT_TYPECLASS = "game.gamesrc.objects.myexit.MyExit"
|
||||
|
||||
Note that objects already created in the database will not notice
|
||||
this change, you have to convert them manually e.g. with the
|
||||
this change, you have to convert them manually e.g. with the
|
||||
@typeclass command.
|
||||
|
||||
"""
|
||||
|
|
@ -21,8 +21,8 @@ from ev import Exit
|
|||
class ExampleExit(Exit):
|
||||
"""
|
||||
Exits are connectors between rooms. Exits are normal Objects except
|
||||
they defines the 'destination' property. It also does work in the
|
||||
following methods:
|
||||
they defines the 'destination' property. It also does work in the
|
||||
following methods:
|
||||
|
||||
basetype_setup() - sets default exit locks (to change, use at_object_creation instead)
|
||||
at_cmdset_get() - this auto-creates and caches a command and a command set on itself
|
||||
|
|
@ -33,11 +33,11 @@ class ExampleExit(Exit):
|
|||
go there") if exit traversal fails and an
|
||||
attribute err_traverse is not defined.
|
||||
|
||||
Relevant hooks to overload (compared to other types of Objects):
|
||||
Relevant hooks to overload (compared to other types of Objects):
|
||||
at_before_traverse(traveller) - called just before traversing
|
||||
at_after_traverse(traveller, source_loc) - called just after traversing
|
||||
at_failed_traverse(traveller) - called if traversal failed for some reason. Will
|
||||
not be called if the attribute 'err_traverse' is
|
||||
not be called if the attribute 'err_traverse' is
|
||||
defined, in which case that will simply be echoed.
|
||||
"""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Template for Objects
|
||||
|
||||
Copy this module up one level and name it as you like, then
|
||||
use it as a template to create your own Objects.
|
||||
use it as a template to create your own Objects.
|
||||
|
||||
To make the default commands default to creating objects of your new
|
||||
type (and also change the "fallback" object used when typeclass
|
||||
|
|
@ -13,7 +13,7 @@ your new class, e.g.
|
|||
settings.BASE_OBJECT_TYPECLASS = "game.gamesrc.objects.myobj.MyObj"
|
||||
|
||||
Note that objects already created in the database will not notice
|
||||
this change, you have to convert them manually e.g. with the
|
||||
this change, you have to convert them manually e.g. with the
|
||||
@typeclass command.
|
||||
|
||||
"""
|
||||
|
|
@ -34,19 +34,19 @@ class ExampleObject(Object):
|
|||
methods, such as __init__ and especially never __getattribute__ and
|
||||
__setattr__ since these are used heavily by the typeclass system
|
||||
of Evennia and messing with them might well break things for you.
|
||||
|
||||
|
||||
* Base properties defined/available on all Objects
|
||||
|
||||
key (string) - name of object
|
||||
* Base properties defined/available on all Objects
|
||||
|
||||
key (string) - name of object
|
||||
name (string)- same as key
|
||||
aliases (list of strings) - aliases to the object. Will be saved to database as AliasDB entries but returned as strings.
|
||||
dbref (int, read-only) - unique #id-number. Also "id" can be used.
|
||||
dbobj (Object, read-only) - link to database model. dbobj.typeclass points back to this class
|
||||
typeclass (Object, read-only) - this links back to this class as an identified only. Use self.swap_typeclass() to switch.
|
||||
date_created (string) - time stamp of object creation
|
||||
permissions (list of strings) - list of permission strings
|
||||
|
||||
permissions (list of strings) - list of permission strings
|
||||
|
||||
player (Player) - controlling player (will also return offline player)
|
||||
location (Object) - current location. Is None if this is a room
|
||||
home (Object) - safety start-location
|
||||
|
|
@ -54,19 +54,19 @@ class ExampleObject(Object):
|
|||
has_player (bool, read-only)- will only return *connected* players
|
||||
contents (list of Objects, read-only) - returns all objects inside this object (including exits)
|
||||
exits (list of Objects, read-only) - returns all exits from this object, if any
|
||||
destination (Object) - only set if this object is an exit.
|
||||
destination (Object) - only set if this object is an exit.
|
||||
is_superuser (bool, read-only) - True/False if this user is a superuser
|
||||
|
||||
* Handlers available
|
||||
|
||||
|
||||
* Handlers available
|
||||
|
||||
locks - lock-handler: use locks.add() to add new lock strings
|
||||
db - attribute-handler: store/retrieve database attributes on this self.db.myattr=val, val=self.db.myattr
|
||||
ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
scripts - script-handler. Add new scripts to object with scripts.add()
|
||||
cmdset - cmdset-handler. Use cmdset.add() to add new cmdsets to object
|
||||
nicks - nick-handler. New nicks with nicks.add().
|
||||
|
||||
* Helper methods (see src.objects.objects.py for full headers)
|
||||
* Helper methods (see src.objects.objects.py for full headers)
|
||||
|
||||
search(ostring, global_search=False, attribute_name=None, use_nicks=False, location=None, ignore_errors=False, player=False)
|
||||
execute_cmd(raw_string)
|
||||
|
|
@ -79,21 +79,21 @@ class ExampleObject(Object):
|
|||
swap_typeclass(new_typeclass, clean_attributes=False, no_default=True)
|
||||
access(accessing_obj, access_type='read', default=False)
|
||||
check_permstring(permstring)
|
||||
|
||||
* Hooks (these are class methods, so their arguments should also start with self):
|
||||
|
||||
* Hooks (these are class methods, so their arguments should also start with self):
|
||||
|
||||
basetype_setup() - only called once, used for behind-the-scenes setup. Normally not modified.
|
||||
basetype_posthook_setup() - customization in basetype, after the object has been created; Normally not modified.
|
||||
|
||||
at_object_creation() - only called once, when object is first created. Object customizations go here.
|
||||
at_object_creation() - only called once, when object is first created. Object customizations go here.
|
||||
at_object_delete() - called just before deleting an object. If returning False, deletion is aborted. Note that all objects
|
||||
inside a deleted object are automatically moved to their <home>, they don't need to be removed here.
|
||||
inside a deleted object are automatically moved to their <home>, they don't need to be removed here.
|
||||
|
||||
at_init() - called whenever typeclass is cached from memory, at least once every server restart/reload
|
||||
at_cmdset_get() - this is called just before the command handler requests a cmdset from this object
|
||||
at_first_login() - (player-controlled objects only) called once, the very first time user logs in.
|
||||
at_init() - called whenever typeclass is cached from memory, at least once every server restart/reload
|
||||
at_cmdset_get() - this is called just before the command handler requests a cmdset from this object
|
||||
at_first_login() - (player-controlled objects only) called once, the very first time user logs in.
|
||||
at_pre_login() - (player-controlled objects only) called every time the user connects, after they have identified, before other setup
|
||||
at_post_login() - (player-controlled objects only) called at the end of login, just before setting the player loose in the world.
|
||||
at_post_login() - (player-controlled objects only) called at the end of login, just before setting the player loose in the world.
|
||||
at_disconnect() - (player-controlled objects only) called just before the user disconnects (or goes linkless)
|
||||
at_server_reload() - called before server is reloaded
|
||||
at_server_shutdown() - called just before server is fully shut down
|
||||
|
|
@ -106,15 +106,15 @@ class ExampleObject(Object):
|
|||
at_object_receive(obj, source_location) - called when this object receives another object
|
||||
|
||||
at_before_traverse(traversing_object) - (exit-objects only) called just before an object traverses this object
|
||||
at_after_traverse(traversing_object, source_location) - (exit-objects only) called just after a traversal has happened.
|
||||
at_after_traverse(traversing_object, source_location) - (exit-objects only) called just after a traversal has happened.
|
||||
at_failed_traverse(traversing_object) - (exit-objects only) called if traversal fails and property err_traverse is not defined.
|
||||
|
||||
at_msg_receive(self, msg, from_obj=None, data=None) - called when a message (via self.msg()) is sent to this obj.
|
||||
|
||||
at_msg_receive(self, msg, from_obj=None, data=None) - called when a message (via self.msg()) is sent to this obj.
|
||||
If returns false, aborts send.
|
||||
at_msg_send(self, msg, to_obj=None, data=None) - called when this objects sends a message to someone via self.msg().
|
||||
|
||||
at_msg_send(self, msg, to_obj=None, data=None) - called when this objects sends a message to someone via self.msg().
|
||||
|
||||
return_appearance(looker) - describes this object. Used by "look" command by default
|
||||
at_desc(looker=None) - called by 'look' whenever the appearance is requested.
|
||||
at_desc(looker=None) - called by 'look' whenever the appearance is requested.
|
||||
at_get(getter) - called after object has been picked up. Does not stop pickup.
|
||||
at_drop(dropper) - called when this object has been dropped.
|
||||
at_say(speaker, message) - by default, called if an object inside this object speaks
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
Template module for Players
|
||||
|
||||
Copy this module up one level and name it as you like, then
|
||||
use it as a template to create your own Player class.
|
||||
use it as a template to create your own Player class.
|
||||
|
||||
To make the default account login default to using a Player
|
||||
To make the default account login default to using a Player
|
||||
of your new type, change settings.BASE_PLAYER_TYPECLASS to point to
|
||||
your new class, e.g.
|
||||
|
||||
settings.BASE_PLAYER_TYPECLASS = "game.gamesrc.objects.myplayer.MyPlayer"
|
||||
|
||||
Note that objects already created in the database will not notice
|
||||
this change, you have to convert them manually e.g. with the
|
||||
this change, you have to convert them manually e.g. with the
|
||||
@typeclass command.
|
||||
|
||||
"""
|
||||
|
|
@ -20,19 +20,19 @@ from ev import Player
|
|||
|
||||
class ExamplePlayer(Player):
|
||||
"""
|
||||
This class describes the actual OOC player (i.e. the user connecting
|
||||
This class describes the actual OOC player (i.e. the user connecting
|
||||
to the MUD). It does NOT have visual appearance in the game world (that
|
||||
is handled by the character which is connected to this). Comm channels
|
||||
are attended/joined using this object.
|
||||
|
||||
It can be useful e.g. for storing configuration options for your game, but
|
||||
are attended/joined using this object.
|
||||
|
||||
It can be useful e.g. for storing configuration options for your game, but
|
||||
should generally not hold any character-related info (that's best handled
|
||||
on the character level).
|
||||
|
||||
Can be set using BASE_PLAYER_TYPECLASS.
|
||||
|
||||
|
||||
* available properties
|
||||
* available properties
|
||||
|
||||
key (string) - name of player
|
||||
name (string)- wrapper for user.username
|
||||
|
|
@ -41,18 +41,18 @@ class ExamplePlayer(Player):
|
|||
dbobj (Player, read-only) - link to database model. dbobj.typeclass points back to this class
|
||||
typeclass (Player, read-only) - this links back to this class as an identified only. Use self.swap_typeclass() to switch.
|
||||
date_created (string) - time stamp of object creation
|
||||
permissions (list of strings) - list of permission strings
|
||||
permissions (list of strings) - list of permission strings
|
||||
|
||||
user (User, read-only) - django User authorization object
|
||||
obj (Object) - game object controlled by player. 'character' can also be used.
|
||||
sessions (list of Sessions) - sessions connected to this player
|
||||
is_superuser (bool, read-only) - if the connected user is a superuser
|
||||
|
||||
* Handlers
|
||||
* Handlers
|
||||
|
||||
locks - lock-handler: use locks.add() to add new lock strings
|
||||
db - attribute-handler: store/retrieve database attributes on this self.db.myattr=val, val=self.db.myattr
|
||||
ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
scripts - script-handler. Add new scripts to object with scripts.add()
|
||||
cmdset - cmdset-handler. Use cmdset.add() to add new cmdsets to object
|
||||
nicks - nick-handler. New nicks with nicks.add().
|
||||
|
|
@ -71,12 +71,12 @@ class ExamplePlayer(Player):
|
|||
* Hook methods (when re-implementation, remember methods need to have self as first arg)
|
||||
|
||||
basetype_setup()
|
||||
at_player_creation()
|
||||
at_player_creation()
|
||||
|
||||
- note that the following hooks are also found on Objects and are
|
||||
usually handled on the character level:
|
||||
|
||||
at_init()
|
||||
at_init()
|
||||
at_cmdset_get()
|
||||
at_first_login()
|
||||
at_post_login()
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ This is a more advanced example object. It combines functions from
|
|||
script.examples as well as commands.examples to make an interactive
|
||||
button typeclass.
|
||||
|
||||
Create this button with
|
||||
Create this button with
|
||||
|
||||
@create/drop examples.red_button.RedButton
|
||||
@create/drop examples.red_button.RedButton
|
||||
|
||||
Note that if you must drop the button before you can see its messages!
|
||||
Note that if you must drop the button before you can see its messages!
|
||||
"""
|
||||
import random
|
||||
import random
|
||||
from ev import Object
|
||||
from game.gamesrc.scripts.examples import red_button_scripts as scriptexamples
|
||||
from game.gamesrc.commands.examples import cmdset_red_button as cmdsetexamples
|
||||
|
|
@ -18,7 +18,7 @@ from game.gamesrc.commands.examples import cmdset_red_button as cmdsetexamples
|
|||
#
|
||||
# Definition of the object itself
|
||||
#
|
||||
|
||||
|
||||
class RedButton(Object):
|
||||
"""
|
||||
This class describes an evil red button. It will use the script
|
||||
|
|
@ -36,30 +36,30 @@ class RedButton(Object):
|
|||
"""
|
||||
This function is called when object is created. Use this
|
||||
instead of e.g. __init__.
|
||||
"""
|
||||
"""
|
||||
# store desc (default, you can change this at creation time)
|
||||
desc = "This is a large red button, inviting yet evil-looking. "
|
||||
desc += "A closed glass lid protects it."
|
||||
self.db.desc = desc
|
||||
desc += "A closed glass lid protects it."
|
||||
self.db.desc = desc
|
||||
|
||||
# We have to define all the variables the scripts
|
||||
# are checking/using *before* adding the scripts or
|
||||
# they might be deactivated before even starting!
|
||||
self.db.lid_open = False
|
||||
self.db.lamp_works = True
|
||||
# We have to define all the variables the scripts
|
||||
# are checking/using *before* adding the scripts or
|
||||
# they might be deactivated before even starting!
|
||||
self.db.lid_open = False
|
||||
self.db.lamp_works = True
|
||||
self.db.lid_locked = False
|
||||
|
||||
self.cmdset.add_default(cmdsetexamples.DefaultCmdSet, permanent=True)
|
||||
|
||||
# since the cmdsets relevant to the button are added 'on the fly',
|
||||
# we need to setup custom scripts to do this for us (also, these scripts
|
||||
# check so they are valid (i.e. the lid is actually still closed)).
|
||||
# The AddClosedCmdSet script makes sure to add the Closed-cmdset.
|
||||
# check so they are valid (i.e. the lid is actually still closed)).
|
||||
# The AddClosedCmdSet script makes sure to add the Closed-cmdset.
|
||||
self.scripts.add(scriptexamples.ClosedLidState)
|
||||
# the script EventBlinkButton makes the button blink regularly.
|
||||
self.scripts.add(scriptexamples.BlinkButtonEvent)
|
||||
|
||||
# state-changing methods
|
||||
# state-changing methods
|
||||
|
||||
def open_lid(self):
|
||||
"""
|
||||
|
|
@ -68,12 +68,12 @@ class RedButton(Object):
|
|||
"""
|
||||
|
||||
if self.db.lid_open:
|
||||
return
|
||||
return
|
||||
desc = self.db.desc_lid_open
|
||||
if not desc:
|
||||
desc = "This is a large red button, inviting yet evil-looking. "
|
||||
desc += "Its glass cover is open and the button exposed."
|
||||
self.db.desc = desc
|
||||
self.db.desc = desc
|
||||
self.db.lid_open = True
|
||||
|
||||
# with the lid open, we validate scripts; this will clean out
|
||||
|
|
@ -93,13 +93,13 @@ class RedButton(Object):
|
|||
"""
|
||||
|
||||
if not self.db.lid_open:
|
||||
return
|
||||
return
|
||||
desc = self.db.desc_lid_closed
|
||||
if not desc:
|
||||
desc = "This is a large red button, inviting yet evil-looking. "
|
||||
desc += "Its glass cover is closed, protecting it."
|
||||
self.db.desc = desc
|
||||
self.db.lid_open = False
|
||||
desc += "Its glass cover is closed, protecting it."
|
||||
self.db.desc = desc
|
||||
self.db.lid_open = False
|
||||
|
||||
# clean out scripts depending on lid to be open
|
||||
self.scripts.validate()
|
||||
|
|
@ -109,17 +109,17 @@ class RedButton(Object):
|
|||
def break_lamp(self, feedback=True):
|
||||
"""
|
||||
Breaks the lamp in the button, stopping it from blinking.
|
||||
|
||||
|
||||
"""
|
||||
self.db.lamp_works = False
|
||||
self.db.lamp_works = False
|
||||
desc = self.db.desc_lamp_broken
|
||||
if not desc:
|
||||
if not desc:
|
||||
self.db.desc += "\nThe big red button has stopped blinking for the time being."
|
||||
else:
|
||||
self.db.desc = desc
|
||||
|
||||
if feedback and self.location:
|
||||
self.location.msg_contents("The lamp flickers, the button going dark.")
|
||||
self.location.msg_contents("The lamp flickers, the button going dark.")
|
||||
self.scripts.validate()
|
||||
|
||||
def press_button(self, pobject):
|
||||
|
|
@ -129,7 +129,7 @@ class RedButton(Object):
|
|||
"""
|
||||
# deactivate the button so it won't flash/close lid etc.
|
||||
self.scripts.add(scriptexamples.DeactivateButtonEvent)
|
||||
# blind the person pressing the button. Note that this
|
||||
# blind the person pressing the button. Note that this
|
||||
# script is set on the *character* pressing the button!
|
||||
pobject.scripts.add(scriptexamples.BlindedState)
|
||||
|
||||
|
|
@ -140,19 +140,18 @@ class RedButton(Object):
|
|||
The script system will regularly call this
|
||||
function to make the button blink. Now and then
|
||||
it won't blink at all though, to add some randomness
|
||||
to how often the message is echoed.
|
||||
to how often the message is echoed.
|
||||
"""
|
||||
loc = self.location
|
||||
if loc:
|
||||
loc = self.location
|
||||
if loc:
|
||||
rand = random.random()
|
||||
if rand < 0.2:
|
||||
if rand < 0.2:
|
||||
string = "The red button flashes briefly."
|
||||
elif rand < 0.4:
|
||||
string = "The red button blinks invitingly."
|
||||
elif rand < 0.6:
|
||||
string = "The red button flashes. You know you wanna push it!"
|
||||
string = "The red button flashes. You know you wanna push it!"
|
||||
else:
|
||||
# no blink
|
||||
return
|
||||
return
|
||||
loc.msg_contents(string)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Template module for Rooms
|
||||
|
||||
Copy this module up one level and name it as you like, then
|
||||
use it as a template to create your own Objects.
|
||||
use it as a template to create your own Objects.
|
||||
|
||||
To make the default commands (such as @dig) default to creating rooms
|
||||
of your new type, change settings.BASE_ROOM_TYPECLASS to point to
|
||||
|
|
@ -12,7 +12,7 @@ your new class, e.g.
|
|||
settings.BASE_ROOM_TYPECLASS = "game.gamesrc.objects.myroom.MyRoom"
|
||||
|
||||
Note that objects already created in the database will not notice
|
||||
this change, you have to convert them manually e.g. with the
|
||||
this change, you have to convert them manually e.g. with the
|
||||
@typeclass command.
|
||||
|
||||
"""
|
||||
|
|
@ -22,11 +22,11 @@ from ev import Room
|
|||
class ExampleRoom(Room):
|
||||
"""
|
||||
Rooms are like any Object, except their location is None
|
||||
(which is default). They also use basetype_setup() to
|
||||
(which is default). They also use basetype_setup() to
|
||||
add locks so they cannot be puppeted or picked up.
|
||||
(to change that, use at_object_creation instead)
|
||||
|
||||
See examples/object.py for a list of
|
||||
properties and methods available on all Objects.
|
||||
properties and methods available on all Objects.
|
||||
"""
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue