nakedmudv3.6/
nakedmudv3.6/lib/
nakedmudv3.6/lib/help/A/
nakedmudv3.6/lib/help/B/
nakedmudv3.6/lib/help/C/
nakedmudv3.6/lib/help/D/
nakedmudv3.6/lib/help/G/
nakedmudv3.6/lib/help/H/
nakedmudv3.6/lib/help/J/
nakedmudv3.6/lib/help/L/
nakedmudv3.6/lib/help/M/
nakedmudv3.6/lib/help/O/
nakedmudv3.6/lib/help/P/
nakedmudv3.6/lib/help/R/
nakedmudv3.6/lib/help/S/
nakedmudv3.6/lib/help/W/
nakedmudv3.6/lib/logs/
nakedmudv3.6/lib/misc/
nakedmudv3.6/lib/players/
nakedmudv3.6/lib/txt/
nakedmudv3.6/lib/world/
nakedmudv3.6/lib/world/examples/
nakedmudv3.6/lib/world/examples/mproto/
nakedmudv3.6/lib/world/examples/oproto/
nakedmudv3.6/lib/world/examples/reset/
nakedmudv3.6/lib/world/examples/rproto/
nakedmudv3.6/lib/world/examples/trigger/
nakedmudv3.6/lib/world/limbo/
nakedmudv3.6/lib/world/limbo/room/
nakedmudv3.6/lib/world/limbo/rproto/
nakedmudv3.6/src/alias/
nakedmudv3.6/src/dyn_vars/
nakedmudv3.6/src/editor/
nakedmudv3.6/src/example_module/
nakedmudv3.6/src/help2/
nakedmudv3.6/src/set_val/
nakedmudv3.6/src/socials/
nakedmudv3.6/src/time/
################################################################################
#
# auxiliary_example.py
#
# Provides a simple example of how one might install and interact with
# auxiliary data in python. This module installs a new piece of auxiliary data,
# and sets up two new commands that allow people to interact with that auxiliary
# data.
#
################################################################################
from mudsys import add_cmd
import auxiliary
import storage

# Example auxiliary data class. Holds a single string variable that
# people are allowed to get and set the value of
class ExampleAux:
    # Create a new instance of the auxiliary data. If a storage set is supplied,
    # read our values from that
    def __init__(self, set = None):
        if not set:
            self.val = "abcxyz"
        else:
            self.val = set.readString("val")

    # copy the variables in this auxiliary data to another auxiliary data
    def copyTo(self, to):
        to.val = self.val

    # create a duplicate of this auxiliary data
    def copy(self):
        newVal = ExampleAux()
        newVal.val = self.val
        return newVal

    # returns a storage set representation of the auxiliary data
    def store(self):
        set = storage.StorageSet()
        set.storeString("val", self.val)
        return set


# allows people to peek at the value stored in their ExampleAux data
def cmd_getaux(ch, cmd, arg):
    aux = ch.getAuxiliary("example_aux")
    ch.send("The val is " + aux.val)

# allows people to set the value stored in their ExampleAux data
def cmd_setaux(ch, cmd, arg):
    aux = ch.getAuxiliary("example_aux")
    aux.val = arg
    ch.send("val set to " + arg)

# install our auxiliary data on characters when this module is loaded.
# auxiliary data can also be installed onto rooms and objects. You can install
# auxiliary data onto more than one type of thing by comma-separating them in
# the third argument of this method.
auxiliary.install("example_aux", ExampleAux, "character")

# add in our two commands
add_cmd("getaux", None, cmd_getaux, "unconscious", "flying", "admin",
        False, False)
add_cmd("setaux", None, cmd_setaux, "unconscious", "flying", "admin",
        False, False)