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.

class evennia.contrib.ingame_python.typeclasses.EventCharacter(*args, **kwargs)[source]

Bases: evennia.objects.objects.DefaultCharacter

Typeclass to represent a character and call event types.

callbacks[source]

Return the CallbackHandler.

announce_move_from(destination, msg=None, mapping=None)[source]

Called if the move is to be announced. This is called while we are still standing in the old location.

Parameters
  • 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.

announce_move_to(source_location, msg=None, mapping=None)[source]

Called after the move if the move was not quiet. At this point we are standing in the new location.

Parameters
  • 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.

at_before_move(destination)[source]

Called just before starting to move this object to destination.

Parameters

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.

at_after_move(source_location)[source]

Called after move has completed, regardless of quiet mode or not. Allows changes to the object due to the location it is now in.

Parameters

source_location (Object) – Wwhere we came from. This may be None.

at_object_delete()[source]

Called just before the database object is permanently delete()d from the database. If this method returns False, deletion is aborted.

at_post_puppet()[source]

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.

at_pre_unpuppet()[source]

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.

at_before_say(message, **kwargs)[source]

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.

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.

at_say(message, **kwargs)[source]

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.

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:

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.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultCharacter.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultCharacter.MultipleObjectsReturned

path = 'evennia.contrib.ingame_python.typeclasses.EventCharacter'
typename = 'EventCharacter'
class evennia.contrib.ingame_python.typeclasses.EventExit(*args, **kwargs)[source]

Bases: evennia.objects.objects.DefaultExit

Modified exit including management of events.

callbacks[source]

Return the CallbackHandler.

at_traverse(traversing_object, target_location)[source]

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.

Parameters
  • traversing_object (Object) – Object traversing us.

  • target_location (Object) – Where target is going.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultExit.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultExit.MultipleObjectsReturned

path = 'evennia.contrib.ingame_python.typeclasses.EventExit'
typename = 'EventExit'
class evennia.contrib.ingame_python.typeclasses.EventObject(*args, **kwargs)[source]

Bases: evennia.objects.objects.DefaultObject

Default object with management of events.

callbacks[source]

Return the CallbackHandler.

at_get(getter)[source]

Called by the default get command when this object has been picked up.

Parameters

getter (Object) – The object getting this object.

Notes

This hook cannot stop the pickup from happening. Use permissions for that.

at_drop(dropper)[source]

Called by the default drop command when this object has been dropped.

Parameters

dropper (Object) – The object which just dropped this object.

Notes

This hook cannot stop the drop from happening. Use permissions from that.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultObject.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultObject.MultipleObjectsReturned

path = 'evennia.contrib.ingame_python.typeclasses.EventObject'
typename = 'EventObject'
class evennia.contrib.ingame_python.typeclasses.EventRoom(*args, **kwargs)[source]

Bases: evennia.objects.objects.DefaultRoom

Default room with management of events.

callbacks[source]

Return the CallbackHandler.

at_object_delete()[source]

Called just before the database object is permanently delete()d from the database. If this method returns False, deletion is aborted.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultRoom.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultRoom.MultipleObjectsReturned

path = 'evennia.contrib.ingame_python.typeclasses.EventRoom'
typename = 'EventRoom'