Rename the 'extend' module in 'custom' for events

This commit is contained in:
Vincent Le Goff 2017-03-14 12:31:53 -07:00 committed by Griatch
parent f0d5bec05f
commit 1f4095c625
5 changed files with 29 additions and 7 deletions

View file

@ -134,7 +134,7 @@ Here's an example of adding the `can_yell` event to all your rooms:
```python
# In typeclasses/rooms.py
from evennia import DefaultRoom
from evennia.contrib.events.extend import create_event_type
from evennia.contrib.events.custom import create_event_type
class Room(DefaultRoom):
"""
@ -219,7 +219,7 @@ A helper function is really a Python function. Its docstring should be sufficie
### Adding new typeclasses
Adding a new typeclass is not different from extending one, and will obey to the same rules: define the class as you have been accustomed to doing, and create the events with `create_event` under the class definition.
Adding a new typeclass is not different from ing one, and will obey to the same rules: define the class as you have been accustomed to doing, and create the events with `create_event` under the class definition.
Note: events obey the inheritance hierarchy: if you define events on the `Room` class, then create a typeclass inheriting from `Room`, the objects of this latter typeclass will have events of both typeclasses.

View file

@ -6,7 +6,7 @@ from datetime import datetime
from django.conf import settings
from evennia import Command
from evennia.contrib.events.extend import get_event_handler
from evennia.contrib.events.custom import get_event_handler
from evennia.utils.eveditor import EvEditor
from evennia.utils.evtable import EvTable
from evennia.utils.utils import class_from_module, time_format

View file

@ -8,7 +8,7 @@ from Queue import Queue
from evennia import DefaultScript
from evennia import logger
from evennia.contrib.events.exceptions import InterruptEvent
from evennia.contrib.events.extend import connect_event_types, patch_hooks
from evennia.contrib.events.custom import connect_event_types, patch_hooks
from evennia.contrib.events import typeclasses
from evennia.utils.utils import all_from_module

View file

@ -2,9 +2,9 @@
Patched typeclasses for Evennia.
"""
from evennia import DefaultCharacter, DefaultExit
from evennia import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
from evennia import ScriptDB
from evennia.contrib.events.extend import create_event_type, patch_hook
from evennia.contrib.events.custom import create_event_type, patch_hook
from evennia.utils.utils import inherits_from
class PatchedExit(object):
@ -44,7 +44,8 @@ class PatchedExit(object):
exit, exit.location, exit.destination)
# Default events
## Default events
# Exit events
create_event_type(DefaultExit, "can_traverse", ["character", "exit", "room"],
"""
Can the character traverse through this exit?
@ -68,3 +69,24 @@ create_event_type(DefaultExit, "traverse", ["character", "exit",
before traversing, while 'destination' contains the room in which
the character now is.
""")
# Room events
create_event_type(DefaultRoom, "time", ["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 @event/add, like:
@event/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:
@event/add here = time 06-15 12:20
This event will fire every year on June 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.
time: a string containing the current time.
""")