documentation additions and corrections
This commit is contained in:
parent
59f79858cb
commit
4fd1e1d9b7
2 changed files with 20 additions and 10 deletions
|
|
@ -18,7 +18,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||||
self.add(ContainerCmdSet)
|
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
|
## 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
|
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()
|
lock mysterious box = get_from:true()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ or implement the same locks/hooks in your own typeclasses.
|
||||||
|
|
||||||
`ContainerObject` implements the following new methods:
|
`ContainerObject` implements the following new methods:
|
||||||
|
|
||||||
at_pre_get_from(self, getter, target, **kwargs) - called with the pre-get hooks
|
at_pre_get_from(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_put_in(putter, target, **kwargs) - called with the pre-put hooks
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
@ -70,19 +70,19 @@ class ContainerObject(_BASE_OBJECT_TYPECLASS):
|
||||||
|
|
||||||
def at_pre_put_in(self, putter, target, **kwargs):
|
def at_pre_put_in(self, putter, target, **kwargs):
|
||||||
"""
|
"""
|
||||||
This will be called when something attempts to get another object FROM this object,
|
This will be called when something attempts to put another object into this object.
|
||||||
rather than when getting this object itself.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
getter (Object): The actor attempting to take something from this object.
|
putter (Object): The actor attempting to put something in this object.
|
||||||
target (Object): The thing this object contains that is being removed.
|
target (Object): The thing being put into this object.
|
||||||
|
|
||||||
NOTE:
|
NOTE:
|
||||||
To add more complex capacity checks, modify this method on your child typeclass.
|
To add more complex capacity checks, modify this method on your child typeclass.
|
||||||
"""
|
"""
|
||||||
# check if we're already at capacity
|
# check if we're already at capacity
|
||||||
if len(self.contents) >= self.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 False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -209,7 +209,7 @@ class CmdContainerGet(CmdGet):
|
||||||
|
|
||||||
class CmdPut(CmdDrop):
|
class CmdPut(CmdDrop):
|
||||||
"""
|
"""
|
||||||
put something down
|
put an object into something else
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
put <obj> in <container>
|
put <obj> in <container>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue