mirror of
https://github.com/evennia/evennia.git
synced 2026-03-20 06:46:31 +01:00
- Set up a global cleaner event to clean all @destroyed objects every 30 minutes (makes their dbrefs available). - Added the @recover command for recovering @destroyed objects up until the point that the cleaner runs and actually destroys them. This can recover @destroyed objects, rooms and exits to the same state as before @destroy. It could easily be made to recover player objects too, but I'm thinking this would be a security issue. - Added to @dig in order to allow for creating rooms with a particular parent. Also auto-creates exits in each room if desired. The only things that is not implemented is the aliases of the exits, I don't really know how to do that. - Changed the @create command format to match the @dig (it uses : to mark the parent instead of = now, since MUX' @dig reserve = to the exit list.) - Added extra security in the example event to guard against the bug that causes the whole scheduler to freak out if the event_function() gives a traceback. - Changed many instances of type to point to the defines_global.OTYPE instead of giving the integer explicitly. /Starkiel
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
"""
|
|
Simple example of a custom modified object, derived from the base object.
|
|
|
|
If you want to make this your new default object type, move this into
|
|
gamesrc/parents and set SCRIPT_DEFAULT_OBJECT = 'custom_basicobject'
|
|
in game/settings.py.
|
|
|
|
Generally, if you want to conveniently set future objects to inherit from this
|
|
script parent, this files and others like it need to be
|
|
located under the game/gamesrc/parent directory.
|
|
"""
|
|
from game.gamesrc.parents.base.basicobject import BasicObject
|
|
|
|
class CustomBasicObject(BasicObject):
|
|
|
|
def at_object_creation(self):
|
|
"""
|
|
This function is called whenever the object is created. Use
|
|
this instead of __init__ to set start attributes etc on a
|
|
particular object type.
|
|
"""
|
|
|
|
#Set an "sdesc" (short description) attribute on object,
|
|
#defaulting to its given name
|
|
|
|
#get the stored object related to this class
|
|
obj = self.scripted_obj
|
|
|
|
#find out the object's name
|
|
name = obj.get_name(fullname=False,
|
|
show_dbref=False,
|
|
show_flags=False)
|
|
#assign the name to the new attribute
|
|
obj.set_attribute('sdesc',name)
|
|
|
|
def at_object_destruction(self, pobject=None):
|
|
"""
|
|
This is triggered when an object is about to be destroyed via
|
|
@destroy ONLY. If an object is deleted via delete(), it is assumed
|
|
that this method is to be skipped.
|
|
|
|
values:
|
|
* pobject: (Object) The object requesting the action.
|
|
"""
|
|
pass
|
|
|
|
|
|
def class_factory(source_obj):
|
|
"""
|
|
This method is called by any script you retrieve (via the scripthandler). It
|
|
creates an instance of the class and returns it transparently.
|
|
|
|
source_obj: (Object) A reference to the object being scripted (the child).
|
|
"""
|
|
return CustomBasicObject(source_obj)
|