From 1f4095c62504c9b9c03a56389c45632eeb83a3e6 Mon Sep 17 00:00:00 2001 From: Vincent Le Goff Date: Tue, 14 Mar 2017 12:31:53 -0700 Subject: [PATCH] Rename the 'extend' module in 'custom' for events --- evennia/contrib/events/README.md | 4 +-- evennia/contrib/events/commands.py | 2 +- .../contrib/events/{extend.py => custom.py} | 0 evennia/contrib/events/scripts.py | 2 +- evennia/contrib/events/typeclasses.py | 28 +++++++++++++++++-- 5 files changed, 29 insertions(+), 7 deletions(-) rename evennia/contrib/events/{extend.py => custom.py} (100%) diff --git a/evennia/contrib/events/README.md b/evennia/contrib/events/README.md index 1cc8ceed3..e23a3765c 100644 --- a/evennia/contrib/events/README.md +++ b/evennia/contrib/events/README.md @@ -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. diff --git a/evennia/contrib/events/commands.py b/evennia/contrib/events/commands.py index 355427db4..42b032aba 100644 --- a/evennia/contrib/events/commands.py +++ b/evennia/contrib/events/commands.py @@ -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 diff --git a/evennia/contrib/events/extend.py b/evennia/contrib/events/custom.py similarity index 100% rename from evennia/contrib/events/extend.py rename to evennia/contrib/events/custom.py diff --git a/evennia/contrib/events/scripts.py b/evennia/contrib/events/scripts.py index ce87046c8..058dc17fd 100644 --- a/evennia/contrib/events/scripts.py +++ b/evennia/contrib/events/scripts.py @@ -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 diff --git a/evennia/contrib/events/typeclasses.py b/evennia/contrib/events/typeclasses.py index 00bcd7443..cefa1a6b7 100644 --- a/evennia/contrib/events/typeclasses.py +++ b/evennia/contrib/events/typeclasses.py @@ -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. +""") +