From 7fc1f08bc59cdd361dc856110f5378cba8fdeed7 Mon Sep 17 00:00:00 2001 From: InspectorCaracal Date: Thu, 9 Mar 2023 10:37:12 -0700 Subject: [PATCH] documentation additions and corrections --- .../contrib/game_systems/containers/README.md | 14 ++++++++++++-- .../game_systems/containers/containers.py | 16 ++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/evennia/contrib/game_systems/containers/README.md b/evennia/contrib/game_systems/containers/README.md index 54834bf379..e27f7af1d8 100644 --- a/evennia/contrib/game_systems/containers/README.md +++ b/evennia/contrib/game_systems/containers/README.md @@ -18,7 +18,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet): self.add(ContainerCmdSet) ``` -This will replace the default `look` and `get` commands with the container-friendly versions provided by the contrib. +This will replace the default `look` and `get` commands with the container-friendly versions provided by the contrib as well as add a new `put` command. ## Usage @@ -26,7 +26,17 @@ The contrib includes a `ContainerObject` typeclass which has all of the set-up n create bag:game_systems.containers.ContainerObject -To make any other objects usable as containers, all you need to do is set the `get_from` lock type on it. +The contrib's `ContainerObject` comes with a capacity limit of a maximum number of items it can hold. This can be changed per individual object. + +In code: +```py +obj.capacity = 5 +``` +In game: + + set box/capacity = 5 + +You can also make any other objects usable as containers by setting the `get_from` lock type on it. lock mysterious box = get_from:true() diff --git a/evennia/contrib/game_systems/containers/containers.py b/evennia/contrib/game_systems/containers/containers.py index 1440bc1e5a..46e6eee449 100644 --- a/evennia/contrib/game_systems/containers/containers.py +++ b/evennia/contrib/game_systems/containers/containers.py @@ -27,8 +27,8 @@ or implement the same locks/hooks in your own typeclasses. `ContainerObject` implements the following new methods: - at_pre_get_from(self, getter, target, **kwargs) - called with the pre-get hooks - at_pre_put_in(self, putter, target, **kwargs) - called with the pre-put hooks + at_pre_get_from(getter, target, **kwargs) - called with the pre-get hooks + at_pre_put_in(putter, target, **kwargs) - called with the pre-put hooks """ from django.conf import settings @@ -70,19 +70,19 @@ class ContainerObject(_BASE_OBJECT_TYPECLASS): def at_pre_put_in(self, putter, target, **kwargs): """ - This will be called when something attempts to get another object FROM this object, - rather than when getting this object itself. + This will be called when something attempts to put another object into this object. Args: - getter (Object): The actor attempting to take something from this object. - target (Object): The thing this object contains that is being removed. + putter (Object): The actor attempting to put something in this object. + target (Object): The thing being put into this object. NOTE: To add more complex capacity checks, modify this method on your child typeclass. """ # check if we're already at capacity if len(self.contents) >= self.capacity: - putter.msg(f"You can't fit anything else in {self.get_numbered_name(1, putter)[0]}.") + singular, _ = self.get_numbered_name(1, putter) + putter.msg(f"You can't fit anything else in {singular}.") return False return True @@ -209,7 +209,7 @@ class CmdContainerGet(CmdGet): class CmdPut(CmdDrop): """ - put something down + put an object into something else Usage: put in