diff --git a/src/commands/objmanip.py b/src/commands/objmanip.py index 6ded1d3150..89eadb17b4 100644 --- a/src/commands/objmanip.py +++ b/src/commands/objmanip.py @@ -280,6 +280,9 @@ def cmd_create(command): new_object = Object.objects.create_object(odat) source_object.emit_to("You create a new thing: %s" % (new_object,)) + + # Trigger stuff to happen after said object is created. + new_object.scriptlink.at_object_creation() GLOBAL_CMD_TABLE.add_command("@create", cmd_create, priv_tuple=("genperms.builder")) diff --git a/src/script_parents/basicobject.py b/src/script_parents/basicobject.py index 5ad3d8ae10..738c984749 100644 --- a/src/script_parents/basicobject.py +++ b/src/script_parents/basicobject.py @@ -12,12 +12,28 @@ from src.ansi import ANSITable class EvenniaBasicObject(object): def __init__(self, scripted_obj, *args, **kwargs): """ - Get our ducks in a row. + Get our ducks in a row. You should generally never override this. Note + that this will not be called on object creation in a manner typical to + most Python objects. This is only called when the script parent is + cached or recalled on an object. This means that this function is not + called until someone does something to warrant calling get_scriptlink(). + + If you're wanting to do something on object/player creation, override + at_object_creation() (in basicobject.py) or at_player_creation() + (in basicplayer.py). scripted_obj: (Object) A reference to the object being scripted (the child). """ self.scripted_obj = scripted_obj + def at_object_creation(self): + """ + This is triggered after a new object is created and ready to go. If + you'd like to set attributes, flags, or do anything when the object + is created, do it here and not in __init__(). + """ + pass + def at_desc(self, pobject=None): """ Perform this action when someone uses the LOOK command on the object. diff --git a/src/script_parents/basicplayer.py b/src/script_parents/basicplayer.py index 2e866c258b..67a8204e16 100644 --- a/src/script_parents/basicplayer.py +++ b/src/script_parents/basicplayer.py @@ -13,7 +13,9 @@ class EvenniaBasicPlayer(object): """ This is triggered after a new User and accompanying Object is created. By the time this is triggered, the player is ready to go but not - logged in. + logged in. Note that this is different from at_object_creation(), which + is executed before at_player_creation(). This function is only + triggered when the User account _and_ the Object are ready. """ pass