Source code for evennia.contrib.ingame_python.typeclasses
-"""
-Typeclasses for the in-game Python system.
-
-To use them, change your base typeclasses to inherit from the classes in this
-module (EventObject, EventRoom, EventCharacter and EventExit) instead of the
-default ones in evennia core.
-
-"""
-
-fromevenniaimportDefaultCharacter,DefaultExit,DefaultObject,DefaultRoom
-fromevenniaimportScriptDB
-fromevennia.utils.utilsimportdelay,inherits_from,lazy_property
-fromevennia.contrib.ingame_python.callbackhandlerimportCallbackHandler
-fromevennia.contrib.ingame_python.utilsimportregister_events,time_event,phrase_event
-
-# Character help
-CHARACTER_CAN_DELETE="""
-Can the character be deleted?
-This event is called before the character is deleted. You can use
-'deny()' in this event to prevent this character from being deleted.
-If this event doesn't prevent the character from being deleted, its
-'delete' event is called right away.
-
-Variables you can use in this event:
- character: the character connected to this event.
-"""
-
-CHARACTER_CAN_MOVE="""
-Can the character move?
-This event is called before the character moves into another
-location. You can prevent the character from moving
-using the 'deny()' eventfunc.
-
-Variables you can use in this event:
- character: the character connected to this event.
- origin: the current location of the character.
- destination: the future location of the character.
-"""
-
-CHARACTER_CAN_PART="""
-Can the departing charaacter leave this room?
-This event is called before another character can move from the
-location where the current character also is. This event can be
-used to prevent someone to leave this room if, for instance, he/she
-hasn't paid, or he/she is going to a protected area, past a guard,
-and so on. Use 'deny()' to prevent the departing character from
-moving.
-
-Variables you can use in this event:
- departing: the character who wants to leave this room.
- character: the character connected to this event.
-"""
-
-CHARACTER_CAN_SAY="""
-Before another character can say something in the same location.
-This event is called before another character says something in the
-character's location. The "something" in question can be modified,
-or the action can be prevented by using 'deny()'. To change the
-content of what the character says, simply change the variable
-'message' to another string of characters.
-
-Variables you can use in this event:
- speaker: the character who is using the say command.
- character: the character connected to this event.
- message: the text spoken by the character.
-"""
-
-CHARACTER_DELETE="""
-Before deleting the character.
-This event is called just before deleting this character. It shouldn't
-be prevented (using the `deny()` function at this stage doesn't
-have any effect). If you want to prevent deletion of this character,
-use the event `can_delete` instead.
-
-Variables you can use in this event:
- character: the character connected to this event.
-"""
-
-CHARACTER_GREET="""
-A new character arrives in the location of this character.
-This event is called when another character arrives in the location
-where the current character is. For instance, a puppeted character
-arrives in the shop of a shopkeeper (assuming the shopkeeper is
-a character). As its name suggests, this event can be very useful
-to have NPC greeting one another, or accounts, who come to visit.
-
-Variables you can use in this event:
- character: the character connected to this event.
- newcomer: the character arriving in the same location.
-"""
-
-CHARACTER_MOVE="""
-After the character has moved into its new room.
-This event is called when the character has moved into a new
-room. It is too late to prevent the move at this point.
-
-Variables you can use in this event:
- character: the character connected to this event.
- origin: the old location of the character.
- destination: the new location of the character.
-"""
-
-CHARACTER_PUPPETED="""
-When the character has been puppeted by an account.
-This event is called when an account has just puppeted this character.
-This can commonly happen when an account connects onto this character,
-or when puppeting to a NPC or free character.
-
-Variables you can use in this event:
- character: the character connected to this event.
-"""
-
-CHARACTER_SAY="""
-After another character has said something in the character's room.
-This event is called right after another character has said
-something in the same location.. The action cannot be prevented
-at this moment. Instead, this event is ideal to create keywords
-that would trigger a character (like a NPC) in doing something
-if a specific phrase is spoken in the same location.
-To use this event, you have to specify a list of keywords as
-parameters that should be present, as separate words, in the
-spoken phrase. For instance, you can set an event tthat would
-fire if the phrase spoken by the character contains "menu" or
-"dinner" or "lunch":
- @call/add ... = say menu, dinner, lunch
-Then if one of the words is present in what the character says,
-this event will fire.
-
-Variables you can use in this event:
- speaker: the character speaking in this room.
- character: the character connected to this event.
- message: the text having been spoken by the character.
-"""
-
-CHARACTER_TIME="""
-A repeated event to be called regularly.
-This event is scheduled to repeat at different times, specified
-as parameters. You can set it to run every day at 8:00 AM (game
-time). You have to specify the time as an argument to @call/add, like:
- @call/add here = time 8:00
-The parameter (8:00 here) must be a suite of digits separated by
-spaces, colons or dashes. Keep it as close from a recognizable
-date format, like this:
- @call/add here = time 06-15 12:20
-This event will fire every year on June the 15th at 12 PM (still
-game time). Units have to be specified depending on your set calendar
-(ask a developer for more details).
-
-Variables you can use in this event:
- character: the character connected to this event.
-"""
-
-CHARACTER_UNPUPPETED="""
-When the character is about to be un-puppeted.
-This event is called when an account is about to un-puppet the
-character, which can happen if the account is disconnecting or
-changing puppets.
-
-Variables you can use in this event:
- character: the character connected to this event.
-"""
-
-
-
[docs]@lazy_property
- defcallbacks(self):
- """Return the CallbackHandler."""
- returnCallbackHandler(self)
-
-
[docs]defannounce_move_from(self,destination,msg=None,mapping=None):
- """
- Called if the move is to be announced. This is
- called while we are still standing in the old
- location.
-
- Args:
- destination (Object): The place we are going to.
- msg (str, optional): a replacement message.
- mapping (dict, optional): additional mapping objects.
-
- You can override this method and call its parent with a
- message to simply change the default message. In the string,
- you can use the following as mappings (between braces):
- object: the object which is moving.
- exit: the exit from which the object is moving (if found).
- origin: the location of the object before the move.
- destination: the location of the object after moving.
-
- """
- ifnotself.location:
- return
-
- string=msgor"{object} is leaving {origin}, heading for {destination}."
-
- # Get the exit from location to destination
- location=self.location
- exits=[
- oforoinlocation.contentsifo.locationislocationando.destinationisdestination
- ]
- mapping=mappingor{}
- mapping.update({"character":self})
-
- ifexits:
- exits[0].callbacks.call(
- "msg_leave",self,exits[0],location,destination,string,mapping
- )
- string=exits[0].callbacks.get_variable("message")
- mapping=exits[0].callbacks.get_variable("mapping")
-
- # If there's no string, don't display anything
- # It can happen if the "message" variable in events is set to None
- ifnotstring:
- return
-
- super().announce_move_from(destination,msg=string,mapping=mapping)
-
-
[docs]defannounce_move_to(self,source_location,msg=None,mapping=None):
- """
- Called after the move if the move was not quiet. At this point
- we are standing in the new location.
-
- Args:
- source_location (Object): The place we came from
- msg (str, optional): the replacement message if location.
- mapping (dict, optional): additional mapping objects.
-
- You can override this method and call its parent with a
- message to simply change the default message. In the string,
- you can use the following as mappings (between braces):
- object: the object which is moving.
- exit: the exit from which the object is moving (if found).
- origin: the location of the object before the move.
- destination: the location of the object after moving.
-
- """
-
- ifnotsource_locationandself.location.has_account:
- # This was created from nowhere and added to an account's
- # inventory; it's probably the result of a create command.
- string="You now have %s in your possession."%self.get_display_name(self.location)
- self.location.msg(string)
- return
-
- ifsource_location:
- string=msgor"{character} arrives to {destination} from {origin}."
- else:
- string="{character} arrives to {destination}."
-
- origin=source_location
- destination=self.location
- exits=[]
- mapping=mappingor{}
- mapping.update({"character":self})
-
- iforigin:
- exits=[
- o
- foroindestination.contents
- ifo.locationisdestinationando.destinationisorigin
- ]
- ifexits:
- exits[0].callbacks.call(
- "msg_arrive",self,exits[0],origin,destination,string,mapping
- )
- string=exits[0].callbacks.get_variable("message")
- mapping=exits[0].callbacks.get_variable("mapping")
-
- # If there's no string, don't display anything
- # It can happen if the "message" variable in events is set to None
- ifnotstring:
- return
-
- super().announce_move_to(source_location,msg=string,mapping=mapping)
-
-
[docs]defat_before_move(self,destination):
- """
- Called just before starting to move this object to
- destination.
-
- Args:
- destination (Object): The object we are moving to
-
- Returns:
- shouldmove (bool): If we should move or not.
-
- Notes:
- If this method returns False/None, the move is cancelled
- before it is even started.
-
- """
- origin=self.location
- Room=DefaultRoom
- ifisinstance(origin,Room)andisinstance(destination,Room):
- can=self.callbacks.call("can_move",self,origin,destination)
- ifcan:
- can=origin.callbacks.call("can_move",self,origin)
- ifcan:
- # Call other character's 'can_part' event
- forpresentin[
- o
- foroinorigin.contents
- ifisinstance(o,DefaultCharacter)andoisnotself
- ]:
- can=present.callbacks.call("can_part",present,self)
- ifnotcan:
- break
-
- ifcanisNone:
- returnTrue
-
- returncan
-
- returnTrue
-
-
[docs]defat_after_move(self,source_location):
- """
- Called after move has completed, regardless of quiet mode or
- not. Allows changes to the object due to the location it is
- now in.
-
- Args:
- source_location (Object): Wwhere we came from. This may be `None`.
-
- """
- super().at_after_move(source_location)
-
- origin=source_location
- destination=self.location
- Room=DefaultRoom
- ifisinstance(origin,Room)andisinstance(destination,Room):
- self.callbacks.call("move",self,origin,destination)
- destination.callbacks.call("move",self,origin,destination)
-
- # Call the 'greet' event of characters in the location
- forpresentin[
- oforoindestination.contentsifisinstance(o,DefaultCharacter)andoisnotself
- ]:
- present.callbacks.call("greet",present,self)
-
-
[docs]defat_object_delete(self):
- """
- Called just before the database object is permanently
- delete()d from the database. If this method returns False,
- deletion is aborted.
-
- """
- ifnotself.callbacks.call("can_delete",self):
- returnFalse
-
- self.callbacks.call("delete",self)
- returnTrue
-
-
[docs]defat_post_puppet(self):
- """
- Called just after puppeting has been completed and all
- Account<->Object links have been established.
-
- Note:
- You can use `self.account` and `self.sessions.get()` to get
- account and sessions at this point; the last entry in the
- list from `self.sessions.get()` is the latest Session
- puppeting this Object.
-
- """
- super().at_post_puppet()
-
- self.callbacks.call("puppeted",self)
-
- # Call the room's puppeted_in event
- location=self.location
- iflocationandisinstance(location,DefaultRoom):
- location.callbacks.call("puppeted_in",self,location)
-
-
[docs]defat_pre_unpuppet(self):
- """
- Called just before beginning to un-connect a puppeting from
- this Account.
-
- Note:
- You can use `self.account` and `self.sessions.get()` to get
- account and sessions at this point; the last entry in the
- list from `self.sessions.get()` is the latest Session
- puppeting this Object.
-
- """
- self.callbacks.call("unpuppeted",self)
-
- # Call the room's unpuppeted_in event
- location=self.location
- iflocationandisinstance(location,DefaultRoom):
- location.callbacks.call("unpuppeted_in",self,location)
-
- super().at_pre_unpuppet()
-
-
[docs]defat_before_say(self,message,**kwargs):
- """
- Before the object says something.
-
- This hook is by default used by the 'say' and 'whisper'
- commands as used by this command it is called before the text
- is said/whispered and can be used to customize the outgoing
- text from the object. Returning `None` aborts the command.
-
- Args:
- message (str): The suggested say/whisper text spoken by self.
- Keyword Args:
- whisper (bool): If True, this is a whisper rather than
- a say. This is sent by the whisper command by default.
- Other verbal commands could use this hook in similar
- ways.
- receiver (Object): If set, this is a target for the say/whisper.
-
- Returns:
- message (str): The (possibly modified) text to be spoken.
-
- """
- # First, try the location
- location=getattr(self,"location",None)
- location=(
- location
- iflocationandinherits_from(location,"evennia.objects.objects.DefaultRoom")
- elseNone
- )
- iflocationandnotkwargs.get("whisper",False):
- allow=location.callbacks.call("can_say",self,location,message,parameters=message)
- message=location.callbacks.get_variable("message")
- ifnotallowornotmessage:
- return
-
- # Browse all the room's other characters
- forobjinlocation.contents:
- ifobjisselfornotinherits_from(
- obj,"evennia.objects.objects.DefaultCharacter"
- ):
- continue
-
- allow=obj.callbacks.call("can_say",self,obj,message,parameters=message)
- message=obj.callbacks.get_variable("message")
- ifnotallowornotmessage:
- return
-
- returnmessage
-
-
[docs]defat_say(self,message,**kwargs):
- """
- Display the actual say (or whisper) of self.
-
- This hook should display the actual say/whisper of the object in its
- location. It should both alert the object (self) and its
- location that some text is spoken. The overriding of messages or
- `mapping` allows for simple customization of the hook without
- re-writing it completely.
-
- Args:
- message (str): The text to be conveyed by self.
- msg_self (str, optional): The message to echo to self.
- msg_location (str, optional): The message to echo to self's location.
- receiver (Object, optional): An eventual receiver of the message
- (by default only used by whispers).
- msg_receiver(str, optional): Specific message for receiver only.
- mapping (dict, optional): Additional mapping in messages.
- Keyword Args:
- whisper (bool): If this is a whisper rather than a say. Kwargs
- can be used by other verbal commands in a similar way.
-
- Notes:
-
- Messages can contain {} markers, which must
- If used, `msg_self`, `msg_receiver` and `msg_location` should contain
- references to other objects between braces, the way `location.msg_contents`
- would allow. For instance:
- msg_self = 'You say: "{speech}"'
- msg_location = '{object} says: "{speech}"'
- msg_receiver = '{object} whispers: "{speech}"'
-
- The following mappings can be used in both messages:
- object: the object speaking.
- location: the location where object is.
- speech: the text spoken by self.
-
- You can use additional mappings if you want to add other
- information in your messages.
-
- """
-
- super().at_say(message,**kwargs)
- location=getattr(self,"location",None)
- location=(
- location
- iflocationandinherits_from(location,"evennia.objects.objects.DefaultRoom")
- elseNone
- )
-
- iflocationandnotkwargs.get("whisper",False):
- location.callbacks.call("say",self,location,message,parameters=message)
-
- # Call the other characters' "say" event
- presents=[
- obj
- forobjinlocation.contents
- ifobjisnotself
- andinherits_from(obj,"evennia.objects.objects.DefaultCharacter")
- ]
- forpresentinpresents:
- present.callbacks.call("say",self,present,message,parameters=message)
-
-
-# Exit help
-EXIT_CAN_TRAVERSE="""
-Can the character traverse through this exit?
-This event is called when a character is about to traverse this
-exit. You can use the deny() function to deny the character from
-exitting for this time.
-
-Variables you can use in this event:
- character: the character that wants to traverse this exit.
- exit: the exit to be traversed.
- room: the room in which stands the character before moving.
-"""
-
-EXIT_MSG_ARRIVE="""
-Customize the message when a character arrives through this exit.
-This event is called when a character arrives through this exit.
-To customize the message that will be sent to the room where the
-character arrives, change the value of the variable "message"
-to give it your custom message. The character itself will not be
-notified. You can use mapping between braces, like this:
- message = "{character} climbs out of a hole."
-In your mapping, you can use {character} (the character who has
-arrived), {exit} (the exit), {origin} (the room in which
-the character was), and {destination} (the room in which the character
-now is). If you need to customize the message with other information,
-you can also set "message" to None and send something else instead.
-
-Variables you can use in this event:
- character: the character who is arriving through this exit.
- exit: the exit having been traversed.
- origin: the past location of the character.
- destination: the current location of the character.
- message: the message to be displayed in the destination.
- mapping: a dictionary containing the mapping of the message.
-"""
-
-EXIT_MSG_LEAVE="""
-Customize the message when a character leaves through this exit.
-This event is called when a character leaves through this exit.
-To customize the message that will be sent to the room where the
-character came from, change the value of the variable "message"
-to give it your custom message. The character itself will not be
-notified. You can use mapping between braces, like this:
- message = "{character} falls into a hole!"
-In your mapping, you can use {character} (the character who is
-about to leave), {exit} (the exit), {origin} (the room in which
-the character is), and {destination} (the room in which the character
-is heading for). If you need to customize the message with other
-information, you can also set "message" to None and send something
-else instead.
-
-Variables you can use in this event:
- character: the character who is leaving through this exit.
- exit: the exit being traversed.
- origin: the location of the character.
- destination: the destination of the character.
- message: the message to be displayed in the location.
- mapping: a dictionary containing additional mapping.
-"""
-
-EXIT_TIME="""
-A repeated event to be called regularly.
-This event is scheduled to repeat at different times, specified
-as parameters. You can set it to run every day at 8:00 AM (game
-time). You have to specify the time as an argument to @call/add, like:
- @call/add north = time 8:00
-The parameter (8:00 here) must be a suite of digits separated by
-spaces, colons or dashes. Keep it as close from a recognizable
-date format, like this:
- @call/add south = time 06-15 12:20
-This event will fire every year on June the 15th at 12 PM (still
-game time). Units have to be specified depending on your set calendar
-(ask a developer for more details).
-
-Variables you can use in this event:
- exit: the exit connected to this event.
-"""
-
-EXIT_TRAVERSE="""
-After the characer has traversed through this exit.
-This event is called after a character has traversed through this
-exit. Traversing cannot be prevented using 'deny()' at this
-point. The character will be in a different room and she will
-have received the room's description when this event is called.
-
-Variables you can use in this event:
- character: the character who has traversed through this exit.
- exit: the exit that was just traversed through.
- origin: the exit's location (where the character was before moving).
- destination: the character's location after moving.
-"""
-
-
-
[docs]@lazy_property
- defcallbacks(self):
- """Return the CallbackHandler."""
- returnCallbackHandler(self)
-
-
[docs]defat_traverse(self,traversing_object,target_location):
- """
- This hook is responsible for handling the actual traversal,
- normally by calling
- `traversing_object.move_to(target_location)`. It is normally
- only implemented by Exit objects. If it returns False (usually
- because `move_to` returned False), `at_after_traverse` below
- should not be called and instead `at_failed_traverse` should be
- called.
-
- Args:
- traversing_object (Object): Object traversing us.
- target_location (Object): Where target is going.
-
- """
- is_character=inherits_from(traversing_object,DefaultCharacter)
- ifis_character:
- allow=self.callbacks.call("can_traverse",traversing_object,self,self.location)
- ifnotallow:
- return
-
- super().at_traverse(traversing_object,target_location)
-
- # After traversing
- ifis_character:
- self.callbacks.call(
- "traverse",traversing_object,self,self.location,self.destination
- )
-
-
-# Object help
-OBJECT_DROP="""
-When a character drops this object.
-This event is called when a character drops this object. It is
-called after the command has ended and displayed its message, and
-the action cannot be prevented at this time.
-
-Variables you can use in this event:
- character: the character having dropped the object.
- obj: the object connected to this event.
-"""
-
-OBJECT_GET="""
-When a character gets this object.
-This event is called when a character gets this object. It is
-called after the command has ended and displayed its message, and
-the action cannot be prevented at this time.
-
-Variables you can use in this event:
- character: the character having picked up the object.
- obj: the object connected to this event.
-"""
-
-OBJECT_TIME="""
-A repeated event to be called regularly.
-This event is scheduled to repeat at different times, specified
-as parameters. You can set it to run every day at 8:00 AM (game
-time). You have to specify the time as an argument to @call/add, like:
- @call/add here = time 8:00
-The parameter (8:00 here) must be a suite of digits separated by
-spaces, colons or dashes. Keep it as close from a recognizable
-date format, like this:
- @call/add here = time 06-15 12:20
-This event will fire every year on June the 15th at 12 PM (still
-game time). Units have to be specified depending on your set calendar
-(ask a developer for more details).
-
-Variables you can use in this event:
- object: the object connected to this event.
-"""
-
-
-
[docs]@lazy_property
- defcallbacks(self):
- """Return the CallbackHandler."""
- returnCallbackHandler(self)
-
-
[docs]defat_get(self,getter):
- """
- Called by the default `get` command when this object has been
- picked up.
-
- Args:
- getter (Object): The object getting this object.
-
- Notes:
- This hook cannot stop the pickup from happening. Use
- permissions for that.
-
- """
- super().at_get(getter)
- self.callbacks.call("get",getter,self)
-
-
[docs]defat_drop(self,dropper):
- """
- Called by the default `drop` command when this object has been
- dropped.
-
- Args:
- dropper (Object): The object which just dropped this object.
-
- Notes:
- This hook cannot stop the drop from happening. Use
- permissions from that.
-
- """
- super().at_drop(dropper)
- self.callbacks.call("drop",dropper,self)
-
-
-# Room help
-ROOM_CAN_DELETE="""
-Can the room be deleted?
-This event is called before the room is deleted. You can use
-'deny()' in this event to prevent this room from being deleted.
-If this event doesn't prevent the room from being deleted, its
-'delete' event is called right away.
-
-Variables you can use in this event:
- room: the room connected to this event.
-"""
-
-ROOM_CAN_MOVE="""
-Can the character move into this room?
-This event is called before the character can move into this
-specific room. You can prevent the move by using the 'deny()'
-function.
-
-Variables you can use in this event:
- character: the character who wants to move in this room.
- room: the room connected to this event.
-"""
-
-ROOM_CAN_SAY="""
-Before a character can say something in this room.
-This event is called before a character says something in this
-room. The "something" in question can be modified, or the action
-can be prevented by using 'deny()'. To change the content of what
-the character says, simply change the variable 'message' to another
-string of characters.
-
-Variables you can use in this event:
- character: the character who is using the say command.
- room: the room connected to this event.
- message: the text spoken by the character.
-"""
-
-ROOM_DELETE="""
-Before deleting the room.
-This event is called just before deleting this room. It shouldn't
-be prevented (using the `deny()` function at this stage doesn't
-have any effect). If you want to prevent deletion of this room,
-use the event `can_delete` instead.
-
-Variables you can use in this event:
- room: the room connected to this event.
-"""
-
-ROOM_MOVE="""
-After the character has moved into this room.
-This event is called when the character has moved into this
-room. It is too late to prevent the move at this point.
-
-Variables you can use in this event:
- character: the character connected to this event.
- origin: the old location of the character.
- destination: the new location of the character.
-"""
-
-ROOM_PUPPETED_IN="""
-After the character has been puppeted in this room.
-This event is called after a character has been puppeted in this
-room. This can happen when an account, having connected, begins
-to puppet a character. The character's location at this point,
-if it's a room, will see this event fire.
-
-Variables you can use in this event:
- character: the character who have just been puppeted in this room.
- room: the room connected to this event.
-"""
-
-ROOM_SAY="""
-After the character has said something in the room.
-This event is called right after a character has said something
-in this room. The action cannot be prevented at this moment.
-Instead, this event is ideal to create actions that will respond
-to something being said aloud. To use this event, you have to
-specify a list of keywords as parameters that should be present,
-as separate words, in the spoken phrase. For instance, you can
-set an event tthat would fire if the phrase spoken by the character
-contains "menu" or "dinner" or "lunch":
- @call/add ... = say menu, dinner, lunch
-Then if one of the words is present in what the character says,
-this event will fire.
-
-Variables you can use in this event:
- character: the character having spoken in this room.
- room: the room connected to this event.
- message: the text having been spoken by the character.
-"""
-
-ROOM_TIME="""
-A repeated event to be called regularly.
-This event is scheduled to repeat at different times, specified
-as parameters. You can set it to run every day at 8:00 AM (game
-time). You have to specify the time as an argument to @call/add, like:
- @call/add here = time 8:00
-The parameter (8:00 here) must be a suite of digits separated by
-spaces, colons or dashes. Keep it as close from a recognizable
-date format, like this:
- @call/add here = time 06-15 12:20
-This event will fire every year on June the 15th at 12 PM (still
-game time). Units have to be specified depending on your set calendar
-(ask a developer for more details).
-
-Variables you can use in this event:
- room: the room connected to this event.
-"""
-
-ROOM_UNPUPPETED_IN="""
-Before the character is un-puppeted in this room.
-This event is called before a character is un-puppeted in this
-room. This can happen when an account, puppeting a character, is
-disconnecting. The character's location at this point, if it's a
-room, will see this event fire.
-
-Variables you can use in this event:
- character: the character who is about to be un-puppeted in this room.
- room: the room connected to this event.
-"""
-
-
-
[docs]@lazy_property
- defcallbacks(self):
- """Return the CallbackHandler."""
- returnCallbackHandler(self)
-
-
[docs]defat_object_delete(self):
- """
- Called just before the database object is permanently
- delete()d from the database. If this method returns False,
- deletion is aborted.
-
- """
- ifnotself.callbacks.call("can_delete",self):
- returnFalse
-
- self.callbacks.call("delete",self)
- returnTrue
[docs]defexample1_build_forest(x,y,**kwargs):
- """A basic example of build instructions. Make sure to include **kwargs
- in the arguments and return an instance of the room for exit generation."""
-
- # Create a room and provide a basic description.
- room=create_object(rooms.Room,key="forest"+str(x)+str(y))
- room.db.desc="Basic forest room."
-
- # Send a message to the account
- kwargs["caller"].msg(room.key+" "+room.dbref)
-
- # This is generally mandatory.
- returnroom
-
-
-
[docs]defexample1_build_mountains(x,y,**kwargs):
- """A room that is a little more advanced"""
-
- # Create the room.
- room=create_object(rooms.Room,key="mountains"+str(x)+str(y))
-
- # Generate a description by randomly selecting an entry from a list.
- room_desc=[
- "Mountains as far as the eye can see",
- "Your path is surrounded by sheer cliffs",
- "Haven't you seen that rock before?",
- ]
- room.db.desc=random.choice(room_desc)
-
- # Create a random number of objects to populate the room.
- foriinrange(randint(0,3)):
- rock=create_object(key="Rock",location=room)
- rock.db.desc="An ordinary rock."
-
- # Send a message to the account
- kwargs["caller"].msg(room.key+" "+room.dbref)
-
- # This is generally mandatory.
- returnroom
-
-
-
[docs]defexample1_build_temple(x,y,**kwargs):
- """A unique room that does not need to be as general"""
-
- # Create the room.
- room=create_object(rooms.Room,key="temple"+str(x)+str(y))
-
- # Set the description.
- room.db.desc=(
- "In what, from the outside, appeared to be a grand and "
- "ancient temple you've somehow found yourself in the the "
- "Evennia Inn! It consists of one large room filled with "
- "tables. The bardisk extends along the east wall, where "
- "multiple barrels and bottles line the shelves. The "
- "barkeep seems busy handing out ale and chatting with "
- "the patrons, which are a rowdy and cheerful lot, "
- "keeping the sound level only just below thunderous. "
- "This is a rare spot of mirth on this dread moor."
- )
-
- # Send a message to the account
- kwargs["caller"].msg(room.key+" "+room.dbref)
-
- # This is generally mandatory.
- returnroom
[docs]defexample2_build_forest(x,y,**kwargs):
- """A basic room"""
- # If on anything other than the first iteration - Do nothing.
- ifkwargs["iteration"]>0:
- returnNone
-
- room=create_object(rooms.Room,key="forest"+str(x)+str(y))
- room.db.desc="Basic forest room."
-
- kwargs["caller"].msg(room.key+" "+room.dbref)
-
- returnroom
-
-
-
[docs]defexample2_build_verticle_exit(x,y,**kwargs):
- """Creates two exits to and from the two rooms north and south."""
- # If on the first iteration - Do nothing.
- ifkwargs["iteration"]==0:
- return
-
- north_room=kwargs["room_dict"][(x,y-1)]
- south_room=kwargs["room_dict"][(x,y+1)]
-
- # create exits in the rooms
- create_object(
- exits.Exit,key="south",aliases=["s"],location=north_room,destination=south_room
- )
-
- create_object(
- exits.Exit,key="north",aliases=["n"],location=south_room,destination=north_room
- )
-
- kwargs["caller"].msg("Connected: "+north_room.key+" & "+south_room.key)
-
-
-
[docs]defexample2_build_horizontal_exit(x,y,**kwargs):
- """Creates two exits to and from the two rooms east and west."""
- # If on the first iteration - Do nothing.
- ifkwargs["iteration"]==0:
- return
-
- west_room=kwargs["room_dict"][(x-1,y)]
- east_room=kwargs["room_dict"][(x+1,y)]
-
- create_object(exits.Exit,key="east",aliases=["e"],location=west_room,destination=east_room)
-
- create_object(exits.Exit,key="west",aliases=["w"],location=east_room,destination=west_room)
-
- kwargs["caller"].msg("Connected: "+west_room.key+" & "+east_room.key)
-
-
-# Include your trigger characters and build functions in a legend dict.
-EXAMPLE2_LEGEND={
- ("β£","β "):example2_build_forest,
- ("|"):example2_build_verticle_exit,
- ("-"):example2_build_horizontal_exit,
-}
-
-# ---------- END OF EXAMPLES ---------- #
-
-COMMAND_DEFAULT_CLASS=utils.class_from_module(settings.COMMAND_DEFAULT_CLASS)
-
-
-# Helper function for readability.
-def_map_to_list(game_map):
- """
- Splits multi line map string into list of rows.
-
- Args:
- game_map (str): An ASCII map
-
- Returns:
- list (list): The map split into rows
-
- """
- returngame_map.split("\n")
-
-
-
[docs]defbuild_map(caller,game_map,legend,iterations=1,build_exits=True):
- """
- Receives the fetched map and legend vars provided by the player.
-
- Args:
- caller (Object): The creator of the map.
- game_map (str): An ASCII map string.
- legend (dict): Mapping of map symbols to object types.
- iterations (int): The number of iteration passes.
- build_exits (bool): Create exits between new rooms.
-
- Notes:
- The map
- is iterated over character by character, comparing it to the trigger
- characters in the legend var and executing the build instructions on
- finding a match. The map is iterated over according to the `iterations`
- value and exits are optionally generated between adjacent rooms according
- to the `build_exits` value.
-
- """
-
- # Split map string to list of rows and create reference list.
- caller.msg("Creating Map...")
- caller.msg(game_map)
- game_map=_map_to_list(game_map)
-
- # Create a reference dictionary which be passed to build functions and
- # will store obj returned by build functions so objs can be referenced.
- room_dict={}
-
- caller.msg("Creating Landmass...")
- foriterationinrange(iterations):
- foryinrange(len(game_map)):
- forxinrange(len(game_map[y])):
- forkeyinlegend:
- # obs - we must use == for strings
- ifgame_map[y][x]==key:
- room=legend[key](
- x,y,iteration=iteration,room_dict=room_dict,caller=caller
- )
- ifiteration==0:
- room_dict[(x,y)]=room
-
- ifbuild_exits:
- # Creating exits. Assumes single room object in dict entry
- caller.msg("Connecting Areas...")
- forloc_key,locationinroom_dict.items():
- x=loc_key[0]
- y=loc_key[1]
-
- # north
- if(x,y-1)inroom_dict:
- ifroom_dict[(x,y-1)]:
- create_object(
- exits.Exit,
- key="north",
- aliases=["n"],
- location=location,
- destination=room_dict[(x,y-1)],
- )
-
- # east
- if(x+1,y)inroom_dict:
- ifroom_dict[(x+1,y)]:
- create_object(
- exits.Exit,
- key="east",
- aliases=["e"],
- location=location,
- destination=room_dict[(x+1,y)],
- )
-
- # south
- if(x,y+1)inroom_dict:
- ifroom_dict[(x,y+1)]:
- create_object(
- exits.Exit,
- key="south",
- aliases=["s"],
- location=location,
- destination=room_dict[(x,y+1)],
- )
-
- # west
- if(x-1,y)inroom_dict:
- ifroom_dict[(x-1,y)]:
- create_object(
- exits.Exit,
- key="west",
- aliases=["w"],
- location=location,
- destination=room_dict[(x-1,y)],
- )
-
- caller.msg("Map Created.")
-
-
-# access command
-
-
-
[docs]classCmdMapBuilder(COMMAND_DEFAULT_CLASS):
- """
- Build a map from a 2D ASCII map.
-
- Usage:
- @mapbuilder[/switch] <path.to.file.MAPNAME> <path.to.file.MAP_LEGEND>
-
- Switches:
- one - execute build instructions once without automatic exit creation
- two - execute build instructions twice without automatic exit creation
-
- Example:
- @mapbuilder world.gamemap.MAP world.maplegend.MAP_LEGEND
- @mapbuilder evennia.contrib.mapbuilder.EXAMPLE1_MAP EXAMPLE1_LEGEND
- @mapbuilder/two evennia.contrib.mapbuilder.EXAMPLE2_MAP EXAMPLE2_LEGEND
- (Legend path defaults to map path)
-
- This is a command which takes two inputs:
- A string of ASCII characters representing a map and a dictionary of
- functions containing build instructions. The characters of the map are
- iterated over and compared to a list of trigger characters. When a match
- is found the corresponding function is executed generating the rooms,
- exits and objects as defined by the users build instructions. If a
- character is not a match to a provided trigger character (including spaces)
- it is simply skipped and the process continues. By default exits are
- automatically generated but is turned off by switches which also determines
- how many times the map is iterated over.
- """
-
- key="@mapbuilder"
- aliases=["@buildmap"]
- locks="cmd:superuser()"
- help_category="Building"
-
-
[docs]deffunc(self):
- """Starts the processor."""
-
- caller=self.caller
- args=self.args.split()
-
- # Check if arguments passed.
- ifnotself.argsor(len(args)!=2):
- caller.msg("Usage: @mapbuilder <path.to.module.VARNAME> ""<path.to.module.MAP_LEGEND>")
- return
-
- # Set up base variables.
- game_map=None
- legend=None
-
- # OBTAIN MAP FROM MODULE
-
- # Breaks down path_to_map into [PATH, VARIABLE]
- path_to_map=args[0]
- path_to_map=path_to_map.rsplit(".",1)
-
- try:
- # Retrieves map variable from module or raises error.
- game_map=utils.variable_from_module(path_to_map[0],path_to_map[1])
- ifnotgame_map:
- raiseValueError(
- "Command Aborted!\n"
- "Path to map variable failed.\n"
- "Usage: @mapbuilder <path.to.module."
- "VARNAME> <path.to.module.MAP_LEGEND>"
- )
-
- exceptExceptionasexc:
- # Or relays error message if fails.
- caller.msg(exc)
- return
-
- # OBTAIN MAP_LEGEND FROM MODULE
-
- # Breaks down path_to_legend into [PATH, VARIABLE]
- path_to_legend=args[1]
- path_to_legend=path_to_legend.rsplit(".",1)
-
- # If no path given default to path_to_map's path
- iflen(path_to_legend)==1:
- path_to_legend.insert(0,path_to_map[0])
-
- try:
- # Retrieves legend variable from module or raises error if fails.
- legend=utils.variable_from_module(path_to_legend[0],path_to_legend[1])
- ifnotlegend:
- raiseValueError(
- "Command Aborted!\n"
- "Path to legend variable failed.\n"
- "Usage: @mapbuilder <path.to.module."
- "VARNAME> <path.to.module.MAP_LEGEND>"
- )
-
- exceptExceptionasexc:
- # Or relays error message if fails.
- caller.msg(exc)
- return
-
- # Set up build_map arguments from switches
- iterations=1
- build_exits=True
-
- if"one"inself.switches:
- build_exits=False
-
- if"two"inself.switches:
- iterations=2
- build_exits=False
-
- # Pass map and legend to the build function.
- build_map(caller,game_map,legend,iterations,build_exits)
-"""
-A login menu using EvMenu.
-
-Contribution - Vincent-lg 2016, Griatch 2019 (rework for modern EvMenu)
-
-This changes the Evennia login to ask for the account name and password in
-sequence instead of requiring you to enter both at once.
-
-To install, add this line to the settings file (`mygame/server/conf/settings.py`):
-
- CMDSET_UNLOGGEDIN = "evennia.contrib.menu_login.UnloggedinCmdSet"
-
-Reload the server and the new connection method will be active. Note that you must
-independently change the connection screen to match this login style, by editing
-`mygame/server/conf/connection_screens.py`.
-
-This uses Evennia's menu system EvMenu and is triggered by a command that is
-called automatically when a new user connects.
-
-"""
-
-fromdjango.confimportsettings
-
-fromevenniaimportCommand,CmdSet
-fromevenniaimportsyscmdkeys
-fromevennia.utils.evmenuimportEvMenu
-fromevennia.utils.utilsimportrandom_string_from_module,class_from_module,callables_from_module
-
-_CONNECTION_SCREEN_MODULE=settings.CONNECTION_SCREEN_MODULE
-_GUEST_ENABLED=settings.GUEST_ENABLED
-_ACCOUNT=class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
-_GUEST=class_from_module(settings.BASE_GUEST_TYPECLASS)
-
-_ACCOUNT_HELP=(
- "Enter the name you used to log into the game before, ""or a new account-name if you are new."
-)
-_PASSWORD_HELP=(
- "Password should be a minimum of 8 characters (preferably longer) and "
- "can contain a mix of letters, spaces, digits and @/./+/-/_/'/, only."
-)
-
-# Menu nodes
-
-
-def_show_help(caller,raw_string,**kwargs):
- """Echo help message, then re-run node that triggered it"""
- help_entry=kwargs["help_entry"]
- caller.msg(help_entry)
- returnNone# re-run calling node
-
-
-
[docs]defnode_enter_username(caller,raw_text,**kwargs):
- """
- Start node of menu
- Start login by displaying the connection screen and ask for a user name.
-
- """
-
- def_check_input(caller,username,**kwargs):
- """
- 'Goto-callable', set up to be called from the _default option below.
-
- Called when user enters a username string. Check if this username already exists and set the flag
- 'new_user' if not. Will also directly login if the username is 'guest'
- and GUEST_ENABLED is True.
-
- The return from this goto-callable determines which node we go to next
- and what kwarg it will be called with.
-
- """
- username=username.rstrip("\n")
-
- ifusername=="guest"and_GUEST_ENABLED:
- # do an immediate guest login
- session=caller
- address=session.address
- account,errors=_GUEST.authenticate(ip=address)
- ifaccount:
- return"node_quit_or_login",{"login":True,"account":account}
- else:
- session.msg("|R{}|n".format("\n".join(errors)))
- returnNone# re-run the username node
-
- try:
- _ACCOUNT.objects.get(username__iexact=username)
- except_ACCOUNT.DoesNotExist:
- new_user=True
- else:
- new_user=False
-
- # pass username/new_user into next node as kwargs
- return"node_enter_password",{"new_user":new_user,"username":username}
-
- callables=callables_from_module(_CONNECTION_SCREEN_MODULE)
- if"connection_screen"incallables:
- connection_screen=callables["connection_screen"]()
- else:
- connection_screen=random_string_from_module(_CONNECTION_SCREEN_MODULE)
-
- if_GUEST_ENABLED:
- text="Enter a new or existing user name to login (write 'guest' for a guest login):"
- else:
- text="Enter a new or existing user name to login:"
- text="{}\n\n{}".format(connection_screen,text)
-
- options=(
- {"key":"","goto":"node_enter_username"},
- {"key":("quit","q"),"goto":"node_quit_or_login"},
- {"key":("help","h"),"goto":(_show_help,{"help_entry":_ACCOUNT_HELP,**kwargs})},
- {"key":"_default","goto":_check_input},
- )
- returntext,options
-
-
-
[docs]defnode_enter_password(caller,raw_string,**kwargs):
- """
- Handle password input.
-
- """
-
- def_check_input(caller,password,**kwargs):
- """
- 'Goto-callable', set up to be called from the _default option below.
-
- Called when user enters a password string. Check username + password
- viability. If it passes, the account will have been created and login
- will be initiated.
-
- The return from this goto-callable determines which node we go to next
- and what kwarg it will be called with.
-
- """
- # these flags were set by the goto-callable
- username=kwargs["username"]
- new_user=kwargs["new_user"]
- password=password.rstrip("\n")
-
- session=caller
- address=session.address
- ifnew_user:
- # create a new account
- account,errors=_ACCOUNT.create(
- username=username,password=password,ip=address,session=session
- )
- else:
- # check password against existing account
- account,errors=_ACCOUNT.authenticate(
- username=username,password=password,ip=address,session=session
- )
-
- ifaccount:
- ifnew_user:
- session.msg("|gA new account |c{}|g was created. Welcome!|n".format(username))
- # pass login info to login node
- return"node_quit_or_login",{"login":True,"account":account}
- else:
- # restart due to errors
- session.msg("|R{}".format("\n".join(errors)))
- kwargs["retry_password"]=True
- return"node_enter_password",kwargs
-
- def_restart_login(caller,*args,**kwargs):
- caller.msg("|yCancelled login.|n")
- return"node_enter_username"
-
- username=kwargs["username"]
- ifkwargs["new_user"]:
-
- ifkwargs.get("retry_password"):
- # Attempting to fix password
- text="Enter a new password:"
- else:
- text="Creating a new account |c{}|n. ""Enter a password (empty to abort):".format(
- username
- )
- else:
- text="Enter the password for account |c{}|n (empty to abort):".format(username)
- options=(
- {"key":"","goto":_restart_login},
- {"key":("quit","q"),"goto":"node_quit_or_login"},
- {"key":("help","h"),"goto":(_show_help,{"help_entry":_PASSWORD_HELP,**kwargs})},
- {"key":"_default","goto":(_check_input,kwargs)},
- )
- returntext,options
-
-
-
[docs]defnode_quit_or_login(caller,raw_text,**kwargs):
- """
- Exit menu, either by disconnecting or logging in.
-
- """
- session=caller
- ifkwargs.get("login"):
- account=kwargs.get("account")
- session.msg("|gLogging in ...|n")
- session.sessionhandler.login(session,account)
- else:
- session.sessionhandler.disconnect(session,"Goodbye! Logging off.")
- return"",{}
-
-
-# EvMenu helper function
-
-
-def_node_formatter(nodetext,optionstext,caller=None):
- """Do not display the options, only the text.
-
- This function is used by EvMenu to format the text of nodes. The menu login
- is just a series of prompts so we disable all automatic display decoration
- and let the nodes handle everything on their own.
-
- """
- returnnodetext
-
-
-# Commands and CmdSets
-
-
-
[docs]classUnloggedinCmdSet(CmdSet):
- "Cmdset for the unloggedin state"
- key="DefaultUnloggedin"
- priority=0
-
-
[docs]defat_cmdset_creation(self):
- "Called when cmdset is first created."
- self.add(CmdUnloggedinLook())
-
-
-
[docs]classCmdUnloggedinLook(Command):
- """
- An unloggedin version of the look command. This is called by the server
- when the account first connects. It sets up the menu before handing off
- to the menu's own look command.
-
- """
-
- key=syscmdkeys.CMD_LOGINSTART
- locks="cmd:all()"
- arg_regex=r"^$"
-
-
[docs]deffunc(self):
- """
- Run the menu using the nodes in this module.
-
- """
- EvMenu(
- self.caller,
- "evennia.contrib.menu_login",
- startnode="node_enter_username",
- auto_look=False,
- auto_quit=False,
- cmd_on_exit=None,
- node_formatter=_node_formatter,
- )
-
-
-
\ No newline at end of file
diff --git a/docs/0.9.5/_modules/evennia/server/portal/portal.html b/docs/0.9.5/_modules/evennia/server/portal/portal.html
index 17035cc0d2..98fa11689f 100644
--- a/docs/0.9.5/_modules/evennia/server/portal/portal.html
+++ b/docs/0.9.5/_modules/evennia/server/portal/portal.html
@@ -72,7 +72,6 @@
fromevennia.server.portal.portalsessionhandlerimportPORTAL_SESSIONSfromevennia.utilsimportloggerfromevennia.server.webserverimportEvenniaReverseProxyResource
-fromdjango.dbimportconnection# we don't need a connection to the database so close it right away
@@ -472,7 +471,9 @@
forplugin_moduleinPORTAL_SERVICES_PLUGIN_MODULES:# external plugin services to start
- plugin_module.start_plugin_services(PORTAL)
+ ifplugin_module:
+ plugin_module.start_plugin_services(PORTAL)
+
diff --git a/docs/0.9.5/_modules/evennia/server/server.html b/docs/0.9.5/_modules/evennia/server/server.html
index 8631e9a235..ff97d23047 100644
--- a/docs/0.9.5/_modules/evennia/server/server.html
+++ b/docs/0.9.5/_modules/evennia/server/server.html
@@ -67,6 +67,7 @@
evennia._init()fromdjango.dbimportconnection
+fromdjango.db.utilsimportOperationalErrorfromdjango.confimportsettingsfromevennia.accounts.modelsimportAccountDB
@@ -246,7 +247,10 @@
self.start_time=time.time()# initialize channelhandler
- channelhandler.CHANNELHANDLER.update()
+ try:
+ channelhandler.CHANNELHANDLER.update()
+ exceptOperationalError:
+ print("channelhandler couldn't update - db not set up")# wrap the SIGINT handler to make sure we empty the threadpool# even when we reload and we have long-running requests in queue.
@@ -657,7 +661,11 @@
# Tell the system the server is starting up; some things are not available yet
-ServerConfig.objects.conf("server_starting_mode",True)
+try:
+ ServerConfig.objects.conf("server_starting_mode",True)
+exceptOperationalError:
+ print("Server server_starting_mode couldn't be set - database not set up.")
+
# twistd requires us to define the variable 'application' so it knows# what to execute from.
@@ -769,7 +777,10 @@
print(f"Could not load plugin module {plugin_module}")# clear server startup mode
-ServerConfig.objects.conf("server_starting_mode",delete=True)
+try:
+ ServerConfig.objects.conf("server_starting_mode",delete=True)
+exceptOperationalError:
+ print("Server server_starting_mode couldn't unset - db not set up.")
diff --git a/docs/0.9.5/_modules/evennia/utils/ansi.html b/docs/0.9.5/_modules/evennia/utils/ansi.html
index cf68f10a99..303a8a1b0b 100644
--- a/docs/0.9.5/_modules/evennia/utils/ansi.html
+++ b/docs/0.9.5/_modules/evennia/utils/ansi.html
@@ -42,8 +42,8 @@
"""ANSI - Gives colour to text.
-Use the codes defined in ANSIPARSER in your text
-to apply colour to text according to the ANSI standard.
+Use the codes defined in ANSIPARSER in your text to apply colour to text
+according to the ANSI standard.Examples:
@@ -51,10 +51,9 @@
"This is |rRed text|n and this is normal again."```
-Mostly you should not need to call `parse_ansi()` explicitly;
-it is run by Evennia just before returning data to/from the
-user. Depreciated example forms are available by extending
-the ansi mapping.
+Mostly you should not need to call `parse_ansi()` explicitly; it is run by
+Evennia just before returning data to/from the user. Depreciated example forms
+are available by extending the ansi mapping."""importfunctools
@@ -122,11 +121,9 @@
[docs]classANSIParser(object):"""
- A class that parses ANSI markup
- to ANSI command sequences
+ A class that parses ANSI markup to ANSI command sequences.
- We also allow to escape colour codes
- by prepending with an extra |.
+ We also allow to escape colour codes by prepending with an extra `|`. """
diff --git a/docs/0.9.5/_modules/evennia/utils/create.html b/docs/0.9.5/_modules/evennia/utils/create.html
index dfc231f939..ee3f1272ff 100644
--- a/docs/0.9.5/_modules/evennia/utils/create.html
+++ b/docs/0.9.5/_modules/evennia/utils/create.html
@@ -137,16 +137,16 @@
location itself or during unittests. attributes (list): Tuples on the form (key, value) or (key, value, category), (key, value, lockstring) or (key, value, lockstring, default_access).
- to set as Attributes on the new object.
+ to set as Attributes on the new object. nattributes (list): Non-persistent tuples on the form (key, value). Note that
- adding this rarely makes sense since this data will not survive a reload.
+ adding this rarely makes sense since this data will not survive a reload. Returns: object (Object): A newly created object of the given typeclass. Raises: ObjectDB.DoesNotExist: If trying to create an Object with
- `location` or `home` that can't be found.
+ `location` or `home` that can't be found. """global_ObjectDB
diff --git a/docs/0.9.5/_modules/evennia/utils/gametime.html b/docs/0.9.5/_modules/evennia/utils/gametime.html
index fb45e7f058..601e62ffa9 100644
--- a/docs/0.9.5/_modules/evennia/utils/gametime.html
+++ b/docs/0.9.5/_modules/evennia/utils/gametime.html
@@ -51,6 +51,7 @@
fromcalendarimportmonthrangefromdatetimeimportdatetime,timedelta
+fromdjango.db.utilsimportOperationalErrorfromdjango.confimportsettingsfromevenniaimportDefaultScriptfromevennia.server.modelsimportServerConfig
@@ -64,7 +65,11 @@
# Only set if gametime_reset was called at some point.
-GAME_TIME_OFFSET=ServerConfig.objects.conf("gametime_offset",default=0)
+try:
+ GAME_TIME_OFFSET=ServerConfig.objects.conf("gametime_offset",default=0)
+exceptOperationalError:
+ print("Gametime offset could not load - db not set up.")
+ GAME_TIME_OFFSET=0# Common real-life time measure, in seconds.# You should not change this.
diff --git a/docs/0.9.5/_modules/evennia/utils/search.html b/docs/0.9.5/_modules/evennia/utils/search.html
index fcd0b6c76c..40353bbb17 100644
--- a/docs/0.9.5/_modules/evennia/utils/search.html
+++ b/docs/0.9.5/_modules/evennia/utils/search.html
@@ -67,6 +67,7 @@
# Import the manager methods to be wrapped
+fromdjango.db.utilsimportOperationalErrorfromdjango.contrib.contenttypes.modelsimportContentType# limit symbol import from API
@@ -84,14 +85,23 @@
# import objects this way to avoid circular import problems
-ObjectDB=ContentType.objects.get(app_label="objects",model="objectdb").model_class()
-AccountDB=ContentType.objects.get(app_label="accounts",model="accountdb").model_class()
-ScriptDB=ContentType.objects.get(app_label="scripts",model="scriptdb").model_class()
-Msg=ContentType.objects.get(app_label="comms",model="msg").model_class()
-Channel=ContentType.objects.get(app_label="comms",model="channeldb").model_class()
-HelpEntry=ContentType.objects.get(app_label="help",model="helpentry").model_class()
-Tag=ContentType.objects.get(app_label="typeclasses",model="tag").model_class()
-
+try:
+ ObjectDB=ContentType.objects.get(app_label="objects",model="objectdb").model_class()
+ AccountDB=ContentType.objects.get(app_label="accounts",model="accountdb").model_class()
+ ScriptDB=ContentType.objects.get(app_label="scripts",model="scriptdb").model_class()
+ Msg=ContentType.objects.get(app_label="comms",model="msg").model_class()
+ ChannelDB=ContentType.objects.get(app_label="comms",model="channeldb").model_class()
+ HelpEntry=ContentType.objects.get(app_label="help",model="helpentry").model_class()
+ Tag=ContentType.objects.get(app_label="typeclasses",model="tag").model_class()
+exceptOperationalError:
+ # this is a fallback used during tests/doc building
+ print("Couldn't initialize search managers - db not set up.")
+ fromevennia.objects.modelsimportObjectDB
+ fromevennia.accounts.modelsimportAccountDB
+ fromevennia.scripts.modelsimportScriptDB
+ fromevennia.comms.modelsimportMsg,ChannelDB
+ fromevennia.help.modelsimportHelpEntry
+ fromevennia.typeclasses.tagsimportTag# -------------------------------------------------------------------# Search manager-wrappers
@@ -211,7 +221,7 @@
# exact - requires an exact ostring match (not case sensitive)#
-search_channel=Channel.objects.channel_search
+search_channel=ChannelDB.objects.channel_searchsearch_channels=search_channelchannel_search=search_channelchannels=search_channels
@@ -272,7 +282,7 @@
defsearch_channel_attribute(key=None,category=None,value=None,strvalue=None,attrtype=None,**kwargs):
- returnChannel.objects.get_by_attribute(
+ returnChannelDB.objects.get_by_attribute(key=key,category=category,value=value,strvalue=strvalue,attrtype=attrtype,**kwargs)
@@ -387,7 +397,7 @@
matches were found. """
- returnChannel.objects.get_by_tag(key=key,category=category,tagtype=tagtype,**kwargs)
+ returnChannelDB.objects.get_by_tag(key=key,category=category,tagtype=tagtype,**kwargs)# search for tag objects (not the objects they are attached to
diff --git a/docs/0.9.5/_modules/evennia/utils/utils.html b/docs/0.9.5/_modules/evennia/utils/utils.html
index dbbadff81f..4810b7f44f 100644
--- a/docs/0.9.5/_modules/evennia/utils/utils.html
+++ b/docs/0.9.5/_modules/evennia/utils/utils.html
@@ -1363,6 +1363,9 @@
mod=mod_import(module)
+ ifnotmod:
+ returndefault
+
ifvariable:result=[]forvarinmake_iter(variable):
@@ -1454,7 +1457,7 @@
returndefault
-
[docs]defclass_from_module(path,defaultpaths=None,fallback=None):""" Return a class from a module, given the module's path. This is primarily used to convert db_typeclass_path:s to classes.
@@ -1463,6 +1466,10 @@
path (str): Full Python dot-path to module. defaultpaths (iterable, optional): If a direct import from `path` fails, try subsequent imports by prepending those paths to `path`.
+ fallback (str): If all other attempts fail, use this path as a fallback.
+ This is intended as a last-resport. In the example of Evennia
+ loading, this would be a path to a default parent class in the
+ evennia repo itself. Returns: class (Class): An uninstatiated class recovered from path.
@@ -1516,7 +1523,13 @@
err+="\nPaths searched:\n%s"%"\n ".join(paths)else:err+="."
- raiseImportError(err)
+ logger.log_err(err)
+ iffallback:
+ logger.log_warn(f"Falling back to {fallback}.")
+ returnclass_from_module(fallback)
+ else:
+ # even fallback fails
+ raiseImportError(err)returncls
diff --git a/docs/0.9.5/_modules/evennia/web/website/forms.html b/docs/0.9.5/_modules/evennia/web/website/forms.html
index a0f9609747..44c573968a 100644
--- a/docs/0.9.5/_modules/evennia/web/website/forms.html
+++ b/docs/0.9.5/_modules/evennia/web/website/forms.html
@@ -93,7 +93,8 @@
"""# The model/typeclass this form creates
- model=class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
+ model=class_from_module(settings.BASE_ACCOUNT_TYPECLASS,
+ fallback=settings.FALLBACK_ACCOUNT_TYPECLASS)# The fields to display on the form, in the given orderfields=("username","email")
@@ -128,7 +129,8 @@
"""# The model/typeclass this form creates
- model=class_from_module(settings.BASE_OBJECT_TYPECLASS)
+ model=class_from_module(settings.BASE_OBJECT_TYPECLASS,
+ fallback=settings.FALLBACK_OBJECT_TYPECLASS)# The fields to display on the form, in the given orderfields=("db_key",)
@@ -181,7 +183,8 @@
"""# Get the correct object model
- model=class_from_module(settings.BASE_CHARACTER_TYPECLASS)
+ model=class_from_module(settings.BASE_CHARACTER_TYPECLASS,
+ fallback=settings.FALLBACK_CHARACTER_TYPECLASS)# Allow entry of the 'key' fieldfields=("db_key",)
diff --git a/docs/0.9.5/_modules/evennia/web/website/tests.html b/docs/0.9.5/_modules/evennia/web/website/tests.html
index fb836f531b..d8d45acd2b 100644
--- a/docs/0.9.5/_modules/evennia/web/website/tests.html
+++ b/docs/0.9.5/_modules/evennia/web/website/tests.html
@@ -166,7 +166,8 @@
[docs]defsetUp(self):super(ChannelDetailTest,self).setUp()
- klass=class_from_module(self.channel_typeclass)
+ klass=class_from_module(self.channel_typeclass,
+ fallback=settings.FALLBACK_CHANNEL_TYPECLASS)# Create a channelklass.create("demo")
diff --git a/docs/0.9.5/_modules/evennia/web/website/views.html b/docs/0.9.5/_modules/evennia/web/website/views.html
index 871201800f..94d30598e9 100644
--- a/docs/0.9.5/_modules/evennia/web/website/views.html
+++ b/docs/0.9.5/_modules/evennia/web/website/views.html
@@ -73,6 +73,7 @@
_BASE_CHAR_TYPECLASS=settings.BASE_CHARACTER_TYPECLASS
+# typeclass fallbacksdef_gamestats():# Some misc. configurable stuff.
@@ -89,11 +90,14 @@
nobjs=ObjectDB.objects.count()nobjs=nobjsor1# fix zero-div error with empty database
- Character=class_from_module(settings.BASE_CHARACTER_TYPECLASS)
+ Character=class_from_module(settings.BASE_CHARACTER_TYPECLASS,
+ fallback=settings.FALLBACK_CHARACTER_TYPECLASS)nchars=Character.objects.all_family().count()
- Room=class_from_module(settings.BASE_ROOM_TYPECLASS)
+ Room=class_from_module(settings.BASE_ROOM_TYPECLASS,
+ fallback=settings.FALLBACK_ROOM_TYPECLASS)nrooms=Room.objects.all_family().count()
- Exit=class_from_module(settings.BASE_EXIT_TYPECLASS)
+ Exit=class_from_module(settings.BASE_EXIT_TYPECLASS,
+ fallback=settings.FALLBACK_EXIT_TYPECLASS)nexits=Exit.objects.all_family().count()nothers=nobjs-nchars-nrooms-nexits
@@ -310,7 +314,8 @@
## So when you extend it, this line should look simple, like:# model = Object
- model=class_from_module(settings.BASE_OBJECT_TYPECLASS)
+ model=class_from_module(settings.BASE_OBJECT_TYPECLASS,
+ fallback=settings.FALLBACK_OBJECT_TYPECLASS)# What HTML template you wish to use to display this page.template_name="website/object_detail.html"
@@ -413,7 +418,8 @@
"""
- model=class_from_module(settings.BASE_OBJECT_TYPECLASS)
-"""
-Account
-
-The Account represents the game "account" and each login has only one
-Account object. An Account is what chats on default channels but has no
-other in-game-world existence. Rather the Account puppets Objects (such
-as Characters) in order to actually participate in the game world.
-
-
-Guest
-
-Guest accounts are simple low-level accounts that are created/deleted
-on the fly and allows users to test the game without the commitment
-of a full registration. Guest accounts are deactivated by default; to
-activate them, add the following line to your settings file:
-
- GUEST_ENABLED = True
-
-You will also need to modify the connection screen to reflect the
-possibility to connect with a guest account. The setting file accepts
-several more options for customizing the Guest account system.
-
-"""
-
-fromevenniaimportDefaultAccount,DefaultGuest
-
-
-classAccount(DefaultAccount):
- """
- This class describes the actual OOC account (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
- should generally not hold any character-related info (that's best handled
- on the character level).
-
- Can be set using BASE_ACCOUNT_TYPECLASS.
-
-
- * available properties
-
- key (string) - name of account
- name (string)- wrapper for user.username
- 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.
- date_created (string) - time stamp of object creation
- permissions (list of strings) - list of permission strings
-
- user (User, read-only) - django User authorization object
- obj (Object) - game object controlled by account. 'character' can also be used.
- sessions (list of Sessions) - sessions connected to this account
- is_superuser (bool, read-only) - if the connected user is a superuser
-
- * 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
- 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
-
- msg(text=None, **kwargs)
- execute_cmd(raw_string, session=None)
- search(ostring, global_search=False, attribute_name=None, use_nicks=False, location=None, ignore_errors=False, account=False)
- is_typeclass(typeclass, exact=False)
- swap_typeclass(new_typeclass, clean_attributes=False, no_default=True)
- access(accessing_obj, access_type='read', default=False)
- check_permstring(permstring)
-
- * Hook methods (when re-implementation, remember methods need to have self as first arg)
-
- basetype_setup()
- at_account_creation()
-
- - note that the following hooks are also found on Objects and are
- usually handled on the character level:
-
- at_init()
- at_cmdset_get(**kwargs)
- at_first_login()
- at_post_login(session=None)
- at_disconnect()
- at_message_receive()
- at_message_send()
- at_server_reload()
- at_server_shutdown()
-
- """
-
- pass
-
-
-classGuest(DefaultGuest):
- """
- This class is used for guest logins. Unlike Accounts, Guests and their
- characters are deleted after disconnection.
- """
-
- pass
-
-"""
-Channel
-
-The channel class represents the out-of-character chat-room usable by
-Accounts in-game. It is mostly overloaded to change its appearance, but
-channels can be used to implement many different forms of message
-distribution systems.
-
-Note that sending data to channels are handled via the CMD_CHANNEL
-syscommand (see evennia.syscmds). The sending should normally not need
-to be modified.
-
-"""
-
-fromevenniaimportDefaultChannel
-
-
-classChannel(DefaultChannel):
- """
- Working methods:
- at_channel_creation() - called once, when the channel is created
- has_connection(account) - check if the given account listens to this channel
- connect(account) - connect account to this channel
- disconnect(account) - disconnect account from channel
- access(access_obj, access_type='listen', default=False) - check the
- access on this channel (default access_type is listen)
- delete() - delete this channel
- message_transform(msg, emit=False, prefix=True,
- sender_strings=None, external=False) - called by
- the comm system and triggers the hooks below
- msg(msgobj, header=None, senders=None, sender_strings=None,
- persistent=None, online=False, emit=False, external=False) - main
- send method, builds and sends a new message to channel.
- tempmsg(msg, header=None, senders=None) - wrapper for sending non-persistent
- messages.
- distribute_message(msg, online=False) - send a message to all
- connected accounts on channel, optionally sending only
- to accounts that are currently online (optimized for very large sends)
-
- Useful hooks:
- channel_prefix(msg, emit=False) - how the channel should be
- prefixed when returning to user. Returns a string
- format_senders(senders) - should return how to display multiple
- senders to a channel
- pose_transform(msg, sender_string) - should detect if the
- sender is posing, and if so, modify the string
- format_external(msg, senders, emit=False) - format messages sent
- from outside the game, like from IRC
- format_message(msg, emit=False) - format the message body before
- displaying it to the user. 'emit' generally means that the
- message should not be displayed with the sender's name.
-
- pre_join_channel(joiner) - if returning False, abort join
- post_join_channel(joiner) - called right after successful join
- pre_leave_channel(leaver) - if returning False, abort leave
- post_leave_channel(leaver) - called right after successful leave
- pre_send_message(msg) - runs just before a message is sent to channel
- post_send_message(msg) - called just after message was sent to channel
-
- """
-
- pass
-
-"""
-Characters
-
-Characters are (by default) Objects setup to be puppeted by Accounts.
-They are what you "see" in game. The Character class in this module
-is setup to be the "default" character type created by the default
-creation commands.
-
-"""
-fromevenniaimportDefaultCharacter
-
-
-classCharacter(DefaultCharacter):
- """
- The Character defaults to reimplementing some of base Object's hook methods with the
- following functionality:
-
- at_basetype_setup - always assigns the DefaultCmdSet 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(source_location) - Launches the "look" command after every move.
- at_post_unpuppet(account) - when Account disconnects from the Character, we
- store the current location in the pre_logout_location Attribute and
- move it to a None-location so the "unpuppeted" character
- object does not need to stay on grid. Echoes "Account has disconnected"
- to the room.
- at_pre_puppet - Just before Account re-connects, retrieves the character's
- pre_logout_location Attribute and move it back on the grid.
- at_post_puppet - Echoes "AccountName has entered the game" to the room.
-
- """
-
- pass
-
-"""
-Object
-
-The Object is the "naked" base class for things in the game world.
-
-Note that the default Character, Room and Exit does not inherit from
-this Object, but from their respective default implementations in the
-evennia library. If you want to use this class as a parent to change
-the other types, you can do so by adding this as a multiple
-inheritance.
-
-"""
-fromevenniaimportDefaultObject
-
-
-classObject(DefaultObject):
- """
- This is the root typeclass object, implementing an in-game Evennia
- game object, such as having a location, being able to be
- manipulated or looked at, etc. If you create a new typeclass, it
- must always inherit from this object (or any of the other objects
- in this file, since they all actually inherit from BaseObject, as
- seen in src.object.objects).
-
- The BaseObject class implements several hooks tying into the game
- engine. By re-implementing these hooks you can control the
- system. You should never need to re-implement special Python
- 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
- name (string)- same as key
- dbref (int, read-only) - unique #id-number. Also "id" can be used.
- date_created (string) - time stamp of object creation
-
- account (Account) - controlling account (if any, only set together with
- sessid below)
- sessid (int, read-only) - session id (if any, only set together with
- account above). Use `sessions` handler to get the
- Sessions directly.
- location (Object) - current location. Is None if this is a room
- home (Object) - safety start-location
- has_account (bool, read-only)- will only return *connected* accounts
- 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.
- is_superuser (bool, read-only) - True/False if this user is a superuser
-
- * Handlers available
-
- aliases - alias-handler: use aliases.add/remove/get() to use.
- permissions - permission-handler: use permissions.add/remove() to
- add/remove new perms.
- locks - lock-handler: use locks.add() to add new lock strings
- 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().
- sessions - sessions-handler. Get Sessions connected to this
- object with sessions.get()
- attributes - attribute-handler. Use attributes.add/remove/get.
- db - attribute-handler: Shortcut for attribute-handler. Store/retrieve
- database attributes using 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
-
- * 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, account=False)
- execute_cmd(raw_string)
- msg(text=None, **kwargs)
- msg_contents(message, exclude=None, from_obj=None, **kwargs)
- move_to(destination, quiet=False, emit_to_obj=None, use_destination=True)
- copy(new_key=None)
- delete()
- is_typeclass(typeclass, exact=False)
- 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 args should 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_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.
-
- at_init() - called whenever typeclass is cached from memory,
- at least once every server restart/reload
- at_cmdset_get(**kwargs) - this is called just before the command handler
- requests a cmdset from this object. The kwargs are
- not normally used unless the cmdset is created
- dynamically (see e.g. Exits).
- at_pre_puppet(account)- (account-controlled objects only) called just
- before puppeting
- at_post_puppet() - (account-controlled objects only) called just
- after completing connection account<->object
- at_pre_unpuppet() - (account-controlled objects only) called just
- before un-puppeting
- at_post_unpuppet(account) - (account-controlled objects only) called just
- after disconnecting account<->object link
- at_server_reload() - called before server is reloaded
- at_server_shutdown() - called just before server is fully shut down
-
- at_access(result, accessing_obj, access_type) - called with the result
- of a lock access check on this object. Return value
- does not affect check result.
-
- at_before_move(destination) - called just before moving object
- to the destination. If returns False, move is cancelled.
- announce_move_from(destination) - called in old location, just
- before move, if obj.move_to() has quiet=False
- announce_move_to(source_location) - called in new location, just
- after move, if obj.move_to() has quiet=False
- at_after_move(source_location) - always called after a move has
- been successfully performed.
- at_object_leave(obj, target_location) - called when an object leaves
- this object in any fashion
- at_object_receive(obj, source_location) - called when this object receives
- another object
-
- at_traverse(traversing_object, source_loc) - (exit-objects only)
- handles all moving across the exit, including
- calling the other exit hooks. Use super() to retain
- the default functionality.
- 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, **kwargs) - 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, **kwargs) - 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_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
-
- """
-
- pass
-
diff --git a/docs/0.9.5/api/evennia.commands.default.building.html b/docs/0.9.5/api/evennia.commands.default.building.html
index a22a3a84a6..429ca6906b 100644
--- a/docs/0.9.5/api/evennia.commands.default.building.html
+++ b/docs/0.9.5/api/evennia.commands.default.building.html
@@ -493,7 +493,7 @@ You can specify the /force switch to bypass this confirmation.
diff --git a/docs/0.9.5/api/evennia.commands.default.general.html b/docs/0.9.5/api/evennia.commands.default.general.html
index f2012f055b..f324c8eecf 100644
--- a/docs/0.9.5/api/evennia.commands.default.general.html
+++ b/docs/0.9.5/api/evennia.commands.default.general.html
@@ -194,7 +194,7 @@ for everyone to use, you need build privileges and the alias command.
diff --git a/docs/0.9.5/api/evennia.contrib.dice.html b/docs/0.9.5/api/evennia.contrib.dice.html
index 861da9e1dc..178a527104 100644
--- a/docs/0.9.5/api/evennia.contrib.dice.html
+++ b/docs/0.9.5/api/evennia.contrib.dice.html
@@ -148,7 +148,7 @@ everyone but the person rolling.
diff --git a/docs/0.9.5/api/evennia.contrib.email_login.html b/docs/0.9.5/api/evennia.contrib.email_login.html
index d6ddea8c52..f12acc88b1 100644
--- a/docs/0.9.5/api/evennia.contrib.email_login.html
+++ b/docs/0.9.5/api/evennia.contrib.email_login.html
@@ -120,7 +120,7 @@ there is no object yet before the account has logged in)
To use them, change your base typeclasses to inherit from the classes in this
-module (EventObject, EventRoom, EventCharacter and EventExit) instead of the
-default ones in evennia core.
You can override this method and call its parent with a
-message to simply change the default message. In the string,
-you can use the following as mappings (between braces):
-
-
object: the object which is moving.
-exit: the exit from which the object is moving (if found).
-origin: the location of the object before the move.
-destination: the location of the object after moving.
You can override this method and call its parent with a
-message to simply change the default message. In the string,
-you can use the following as mappings (between braces):
-
-
object: the object which is moving.
-exit: the exit from which the object is moving (if found).
-origin: the location of the object before the move.
-destination: the location of the object after moving.
Called just after puppeting has been completed and all
-Account<->Object links have been established.
-
-
Note
-
You can use self.account and self.sessions.get() to get
-account and sessions at this point; the last entry in the
-list from self.sessions.get() is the latest Session
-puppeting this Object.
Called just before beginning to un-connect a puppeting from
-this Account.
-
-
Note
-
You can use self.account and self.sessions.get() to get
-account and sessions at this point; the last entry in the
-list from self.sessions.get() is the latest Session
-puppeting this Object.
This hook is by default used by the βsayβ and βwhisperβ
-commands as used by this command it is called before the text
-is said/whispered and can be used to customize the outgoing
-text from the object. Returning None aborts the command.
-
-
Parameters
-
message (str) β The suggested say/whisper text spoken by self.
-
-
Keyword Arguments
-
-
whisper (bool) β If True, this is a whisper rather than
-a say. This is sent by the whisper command by default.
-Other verbal commands could use this hook in similar
-ways.
-
receiver (Object) β If set, this is a target for the say/whisper.
-
-
-
Returns
-
message (str) β The (possibly modified) text to be spoken.
This hook should display the actual say/whisper of the object in its
-location. It should both alert the object (self) and its
-location that some text is spoken. The overriding of messages or
-mapping allows for simple customization of the hook without
-re-writing it completely.
-
-
Parameters
-
-
message (str) β The text to be conveyed by self.
-
msg_self (str, optional) β The message to echo to self.
-
msg_location (str, optional) β The message to echo to selfβs location.
-
receiver (Object, optional) β An eventual receiver of the message
-(by default only used by whispers).
-
msg_receiver (str, optional) β Specific message for receiver only.
-
mapping (dict, optional) β Additional mapping in messages.
-
-
-
Keyword Arguments
-
whisper (bool) β If this is a whisper rather than a say. Kwargs
-can be used by other verbal commands in a similar way.
-
-
-
Notes
-
Messages can contain {} markers, which must
-If used, msg_self, msg_receiver and msg_location should contain
-references to other objects between braces, the way location.msg_contents
-would allow. For instance:
This hook is responsible for handling the actual traversal,
-normally by calling
-traversing_object.move_to(target_location). It is normally
-only implemented by Exit objects. If it returns False (usually
-because move_to returned False), at_after_traverse below
-should not be called and instead at_failed_traverse should be
-called.
A string of ASCII characters representing a map and a dictionary of functions
-containing build instructions. The characters of the map are iterated over and
-compared to a list of trigger characters. When a match is found the
-corresponding function is executed generating the rooms, exits and objects as
-defined by the users build instructions. If a character is not a match to
-a provided trigger character (including spaces) it is simply skipped and the
-process continues.
x - The rooms position on the maps x axis
-y - The rooms position on the maps y axis
-caller - The account calling the command
-iteration - The current iterations number (0, 1 or 2)
-room_dict - A dictionary containing room references returned by build
-
-
functions where tuple coordinates are the keys (x, y).
-ie room_dict[(2, 2)] will return the temple room above.
-
-
-
Building functions should return the room they create. By default these rooms
-are used to create exits between valid adjacent rooms to the north, south,
-east and west directions. This behaviour can turned off with the use of switch
-arguments. In addition to turning off automatic exit generation the switches
-allow the map to be iterated over a number of times. This is important for
-something like custom exit building. Exits require a reference to both the
-exits location and the exits destination. During the first iteration it is
-possible that an exit is created pointing towards a destination that
-has not yet been created resulting in error. By iterating over the map twice
-the rooms can be created on the first iteration and room reliant code can be
-be used on the second iteration. The iteration number and a dictionary of
-references to rooms previously created is passed to the build commands.
-
Use by importing and including the command in your default_cmdsets module.
-For example:
-
-
# mygame/commands/default_cmdsets.py
-
from evennia.contrib import mapbuilder
-
β¦
-
self.add(mapbuilder.CmdMapBuilder())
-
-
You then call the command in-game using the path to the MAP and MAP_LEGEND vars
-The path you provide is relative to the evennia or mygame folder.
Below are two examples showcasing the use of automatic exit generation and
-custom exit generation. Whilst located, and can be used, from this module for
-convenience The below example code should be in mymap.py in mygame/world.
-
-
-evennia.contrib.mapbuilder.example1_build_forest(x, y, **kwargs)[source]ΒΆ
-
A basic example of build instructions. Make sure to include **kwargs
-in the arguments and return an instance of the room for exit generation.
-
-
-
-
-evennia.contrib.mapbuilder.example1_build_mountains(x, y, **kwargs)[source]ΒΆ
-
A room that is a little more advanced
-
-
-
-
-evennia.contrib.mapbuilder.example1_build_temple(x, y, **kwargs)[source]ΒΆ
-
A unique room that does not need to be as general
-
-
-
-
-evennia.contrib.mapbuilder.example2_build_forest(x, y, **kwargs)[source]ΒΆ
-
A basic room
-
-
-
-
-evennia.contrib.mapbuilder.example2_build_verticle_exit(x, y, **kwargs)[source]ΒΆ
-
Creates two exits to and from the two rooms north and south.
-
-
-
-
-evennia.contrib.mapbuilder.example2_build_horizontal_exit(x, y, **kwargs)[source]ΒΆ
-
Creates two exits to and from the two rooms east and west.
Receives the fetched map and legend vars provided by the player.
-
-
Parameters
-
-
caller (Object) β The creator of the map.
-
game_map (str) β An ASCII map string.
-
legend (dict) β Mapping of map symbols to object types.
-
iterations (int) β The number of iteration passes.
-
build_exits (bool) β Create exits between new rooms.
-
-
-
-
Notes
-
The map
-is iterated over character by character, comparing it to the trigger
-characters in the legend var and executing the build instructions on
-finding a match. The map is iterated over according to the iterations
-value and exits are optionally generated between adjacent rooms according
-to the build_exits value.
This is a command which takes two inputs:
-A string of ASCII characters representing a map and a dictionary of
-functions containing build instructions. The characters of the map are
-iterated over and compared to a list of trigger characters. When a match
-is found the corresponding function is executed generating the rooms,
-exits and objects as defined by the users build instructions. If a
-character is not a match to a provided trigger character (including spaces)
-it is simply skipped and the process continues. By default exits are
-automatically generated but is turned off by switches which also determines
-how many times the map is iterated over.
Reload the server and the new connection method will be active. Note that you must
-independently change the connection screen to match this login style, by editing
-mygame/server/conf/connection_screens.py.
-
This uses Evenniaβs menu system EvMenu and is triggered by a command that is
-called automatically when a new user connects.
An unloggedin version of the look command. This is called by the server
-when the account first connects. It sets up the menu before handing off
-to the menuβs own look command.
diff --git a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_basic.html b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_basic.html
index 311095c4f0..6a8426493f 100644
--- a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_basic.html
+++ b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_basic.html
@@ -559,7 +559,7 @@ if there are still any actions you can take.
diff --git a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_equip.html b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_equip.html
index f388bd373a..e63b617479 100644
--- a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_equip.html
+++ b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_equip.html
@@ -676,7 +676,7 @@ if there are still any actions you can take.
diff --git a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_items.html b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_items.html
index 30925f735d..c8e4e1b77e 100644
--- a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_items.html
+++ b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_items.html
@@ -710,7 +710,7 @@ if there are still any actions you can take.
diff --git a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_magic.html b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_magic.html
index fcd18b3a49..b38f92a335 100644
--- a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_magic.html
+++ b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_magic.html
@@ -582,7 +582,7 @@ if there are still any actions you can take.
diff --git a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_range.html b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_range.html
index 5c68240d47..c3c6a08dd0 100644
--- a/docs/0.9.5/api/evennia.contrib.turnbattle.tb_range.html
+++ b/docs/0.9.5/api/evennia.contrib.turnbattle.tb_range.html
@@ -994,7 +994,7 @@ if there are still any actions you can take.
diff --git a/docs/0.9.5/api/evennia.contrib.tutorial_examples.cmdset_red_button.html b/docs/0.9.5/api/evennia.contrib.tutorial_examples.cmdset_red_button.html
index 224ef1bda5..e1eebfb57a 100644
--- a/docs/0.9.5/api/evennia.contrib.tutorial_examples.cmdset_red_button.html
+++ b/docs/0.9.5/api/evennia.contrib.tutorial_examples.cmdset_red_button.html
@@ -104,7 +104,7 @@ push the lid of the button away.
diff --git a/docs/0.9.5/api/evennia.contrib.tutorial_world.rooms.html b/docs/0.9.5/api/evennia.contrib.tutorial_world.rooms.html
index 9069c9178a..95c45522e0 100644
--- a/docs/0.9.5/api/evennia.contrib.tutorial_world.rooms.html
+++ b/docs/0.9.5/api/evennia.contrib.tutorial_world.rooms.html
@@ -672,7 +672,7 @@ if they fall off the bridge.
Use the codes defined in ANSIPARSER in your text
-to apply colour to text according to the ANSI standard.
+
Use the codes defined in ANSIPARSER in your text to apply colour to text
+according to the ANSI standard.
Examples:
"This is |rRed text|n and this is normal again."
-
Mostly you should not need to call parse_ansi() explicitly;
-it is run by Evennia just before returning data to/from the
-user. Depreciated example forms are available by extending
-the ansi mapping.
+
Mostly you should not need to call parse_ansi() explicitly; it is run by
+Evennia just before returning data to/from the user. Depreciated example forms
+are available by extending the ansi mapping.
nohome (bool) β This allows the creation of objects without a
default home location; only used when creating the default
location itself or during unittests.
Tuples on the form (key, value) or (key, value, category),
-(key, value, lockstring) or (key, value, lockstring, default_access).
-
-
to set as Attributes on the new object.
-
-
+
attributes (list) β Tuples on the form (key, value) or (key, value, category),
+(key, value, lockstring) or (key, value, lockstring, default_access).
+to set as Attributes on the new object.
nattributes (list) β Non-persistent tuples on the form (key, value). Note that
adding this rarely makes sense since this data will not survive a reload.
@@ -93,8 +90,10 @@ adding this rarely makes sense since this data will not survive a reload.
object (Object) β A newly created object of the given typeclass.
Raises
-
ObjectDB.DoesNotExist β If trying to create an Object with
-location or home that canβt be found.
diff --git a/docs/0.9.5/api/evennia.utils.evmore.html b/docs/0.9.5/api/evennia.utils.evmore.html
index 39eec8f2fa..7727d033d6 100644
--- a/docs/0.9.5/api/evennia.utils.evmore.html
+++ b/docs/0.9.5/api/evennia.utils.evmore.html
@@ -74,7 +74,7 @@ the caller.msg() construct every time the page is updated.
diff --git a/docs/0.9.5/api/evennia.utils.logger.html b/docs/0.9.5/api/evennia.utils.logger.html
index 0678d6728e..e32c0dc490 100644
--- a/docs/0.9.5/api/evennia.utils.logger.html
+++ b/docs/0.9.5/api/evennia.utils.logger.html
@@ -308,7 +308,7 @@ lines of the previous log to the start of the new log, in order
to preserve a continuous chat history for channel log files.
Return a class from a module, given the moduleβs path. This is
primarily used to convert db_typeclass_path:s to classes.
@@ -946,6 +946,10 @@ primarily used to convert db_typeclass_path:s to classes.
path (str) β Full Python dot-path to module.
defaultpaths (iterable, optional) β If a direct import from path fails,
try subsequent imports by prepending those paths to path.
+
fallback (str) β If all other attempts fail, use this path as a fallback.
+This is intended as a last-resport. In the example of Evennia
+loading, this would be a path to a default parent class in the
+evennia repo itself.
Returns
@@ -959,7 +963,7 @@ try subsequent imports by prepending those paths to path.
Return a class from a module, given the moduleβs path. This is
primarily used to convert db_typeclass_path:s to classes.
@@ -968,6 +972,10 @@ primarily used to convert db_typeclass_path:s to classes.
path (str) β Full Python dot-path to module.
defaultpaths (iterable, optional) β If a direct import from path fails,
try subsequent imports by prepending those paths to path.
+
fallback (str) β If all other attempts fail, use this path as a fallback.
+This is intended as a last-resport. In the example of Evennia
+loading, this would be a path to a default parent class in the
+evennia repo itself.
Returns
diff --git a/docs/0.9.5/api/evennia.web.website.forms.html b/docs/0.9.5/api/evennia.web.website.forms.html
index 5fef7b68e0..d9c04535be 100644
--- a/docs/0.9.5/api/evennia.web.website.forms.html
+++ b/docs/0.9.5/api/evennia.web.website.forms.html
@@ -93,7 +93,7 @@ the form.
diff --git a/docs/0.9.5/api/evennia.web.website.views.html b/docs/0.9.5/api/evennia.web.website.views.html
index 6a3df7bd05..0151cf446d 100644
--- a/docs/0.9.5/api/evennia.web.website.views.html
+++ b/docs/0.9.5/api/evennia.web.website.views.html
@@ -193,7 +193,7 @@ permissions to actually do things to it.