rename to at_object_post_spawn and add prototype keyword
This commit is contained in:
parent
958cdd4b10
commit
0b45e483e2
2 changed files with 8 additions and 5 deletions
|
|
@ -310,7 +310,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
False, deletion is aborted. Note that all objects
|
False, deletion is aborted. Note that all objects
|
||||||
inside a deleted object are automatically moved
|
inside a deleted object are automatically moved
|
||||||
to their <home>, they don't need to be removed here.
|
to their <home>, they don't need to be removed here.
|
||||||
at_object_spawn() - called when object is spawned from a prototype or updated
|
at_object_post_spawn() - called when object is spawned from a prototype or updated
|
||||||
by the spawner to apply prototype changes.
|
by the spawner to apply prototype changes.
|
||||||
at_init() - called whenever typeclass is cached from memory,
|
at_init() - called whenever typeclass is cached from memory,
|
||||||
at least once every server restart/reload
|
at least once every server restart/reload
|
||||||
|
|
@ -2050,10 +2050,13 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def at_object_spawn(self):
|
def at_object_post_spawn(self, prototype=None):
|
||||||
"""
|
"""
|
||||||
Called when this object is spawned or updated from a prototype, after all other
|
Called when this object is spawned or updated from a prototype, after all other
|
||||||
hooks have been run.
|
hooks have been run.
|
||||||
|
|
||||||
|
Keyword Args:
|
||||||
|
prototype (dict): The prototype that was used to spawn or update this object.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -803,8 +803,8 @@ def batch_update_objects_with_prototype(
|
||||||
if do_save:
|
if do_save:
|
||||||
changed += 1
|
changed += 1
|
||||||
obj.save()
|
obj.save()
|
||||||
if spawn_hook := getattr(obj, "at_object_spawn", None):
|
if spawn_hook := getattr(obj, "at_object_post_spawn", None):
|
||||||
spawn_hook()
|
spawn_hook(prototype=prototype)
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|
@ -872,7 +872,7 @@ def batch_create_object(*objparams):
|
||||||
if code:
|
if code:
|
||||||
exec(code, {}, {"evennia": evennia, "obj": obj})
|
exec(code, {}, {"evennia": evennia, "obj": obj})
|
||||||
# run the spawned hook
|
# run the spawned hook
|
||||||
if spawn_hook := getattr(obj, "at_object_spawn", None):
|
if spawn_hook := getattr(obj, "at_object_post_spawn", None):
|
||||||
spawn_hook()
|
spawn_hook()
|
||||||
objs.append(obj)
|
objs.append(obj)
|
||||||
return objs
|
return objs
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue