evennia.contrib.grid.slow_exit.slow_exit

Slow Exit typeclass

Contribution - Griatch 2014

This is an example of an Exit-type that delays its traversal. This simulates slow movement, common in many different types of games. The contrib also contains two commands, CmdSetSpeed and CmdStop for changing the movement speed and abort an ongoing traversal, respectively.

Installation:

To try out an exit of this type, you could connect two existing rooms using something like this:

@open north:contrib.grid.slow_exit.SlowExit = <destination>

To make this your new default exit, modify mygame/typeclasses/exits.py to import this module and change the default Exit class to inherit from SlowExit instead.

in mygame/typeclasses/exits.py

from evennia.contrib.grid.slowexit import SlowExit

class Exit(SlowExit):

# …

To get the ability to change your speed and abort your movement, import

# in mygame/commands/default_cmdsets.py

from evennia.contrib.grid import slow_exit  <---

class CharacterCmdSet(default_cmds.CharacterCmdSet):
    # ...
    def at_cmdset_creation(self):
        # ...
        self.add(slow_exit.SlowDoorCmdSet)  <---

Notes:

This implementation is efficient but not persistent; so incomplete movement will be lost in a server reload. This is acceptable for most game types - to simulate longer travel times (more than the couple of seconds assumed here), a more persistent variant using Scripts or the TickerHandler might be better.

class evennia.contrib.grid.slow_exit.slow_exit.SlowExit(*args, **kwargs)[source]

Bases: evennia.objects.objects.DefaultExit

This overloads the way moving happens.

at_traverse(traversing_object, target_location)[source]

Implements the actual traversal, using utils.delay to delay the move_to.

exception DoesNotExist

Bases: evennia.objects.objects.DefaultExit.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultExit.MultipleObjectsReturned

path = 'evennia.contrib.grid.slow_exit.slow_exit.SlowExit'
typename = 'SlowExit'
class evennia.contrib.grid.slow_exit.slow_exit.CmdSetSpeed(**kwargs)[source]

Bases: evennia.commands.command.Command

set your movement speed

Usage:

setspeed stroll|walk|run|sprint

This will set your movement speed, determining how long time it takes to traverse exits. If no speed is set, ‘walk’ speed is assumed.

key = 'setspeed'
func()[source]

Simply sets an Attribute used by the SlowExit above.

aliases = []
help_category = 'general'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'setspeed', 'no_prefix': ' ', 'tags': '', 'text': "\n set your movement speed\n\n Usage:\n setspeed stroll|walk|run|sprint\n\n This will set your movement speed, determining how long time\n it takes to traverse exits. If no speed is set, 'walk' speed\n is assumed.\n "}
class evennia.contrib.grid.slow_exit.slow_exit.CmdStop(**kwargs)[source]

Bases: evennia.commands.command.Command

stop moving

Usage:

stop

Stops the current movement, if any.

key = 'stop'
func()[source]

This is a very simple command, using the stored deferred from the exit traversal above.

aliases = []
help_category = 'general'
lock_storage = 'cmd:all();'
search_index_entry = {'aliases': '', 'category': 'general', 'key': 'stop', 'no_prefix': ' ', 'tags': '', 'text': '\n stop moving\n\n Usage:\n stop\n\n Stops the current movement, if any.\n '}
class evennia.contrib.grid.slow_exit.slow_exit.SlowExitCmdSet(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

path = 'evennia.contrib.grid.slow_exit.slow_exit.SlowExitCmdSet'