Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Space Objects - Stephen 2017
- This module holds all space objects
- Objects:
- SpaceObject
- Console
- Ship
- Station
- Planet
- Nebula
- Debris
- """
- from future.utils import listvalues
- import random
- from evennia import DefaultObject, DefaultExit, Command, CmdSet
- from evennia import utils
- from evennia.utils import search
- from evennia.utils.spawner import spawn
- #------------------------------------------------------------
- #
- # SpaceObject
- #
- # The SpaceObject is the base class for all items
- # in the space system.
- #
- # SpaceObjects may also be "reset". What the reset means
- # is up to the object.
- #------------------------------------------------------------
- class SpaceObject(DefaultObject):
- """
- This is the baseclass for all objects in the space system.
- """
- def at_object_creation(self):
- "Called when the object is first created."
- super(SpaceObject, self).at_object_creation()
- self.caller.msg("DEBUG -- " + self + " added to space system.")
- #evennia.search_channel("Space").msg(self + " added to space system by " + caller + ".")
- def reset(self):
- "Resets the object, whatever that may mean."
- self.location = self.home
- #------------------------------------------------------------
- #
- # Console - an object that can be manned to control
- # space objects: 'man <console>'
- #
- #------------------------------------------------------------
- #
- # man command
- #
- class CmdMan(Command):
- """
- Usage:
- man [obj]
- Man a mannable console.
- """
- key = "man"
- locks = "cmd:all()"
- help_category = "Console"
- def func(self):
- """
- Implements the man command.
- """
- if self.args:
- obj = self.caller.search(self.args.strip())
- else:
- obj = self.obj
- if not obj:
- return
- string = "You can't man %s until the code is complete :)." % obj.key
- self.caller.msg(string)
- class CmdMan(Command):
- """
- Usage:
- man [obj]
- Man a mannable console.
- """
- key = "man"
- locks = "cmd:all()"
- help_category = "Console"
- def func(self):
- """
- Implements the unman command.
- """
- if self.args:
- obj = self.caller.search(self.args.strip())
- else:
- obj = self.obj
- if not obj:
- return
- string = "You can't unman %s until the code is complete :)." % obj.key
- self.caller.msg(string)
- class CmdSetConsole(CmdSet):
- """
- A CmdSet for consoles.
- """
- def at_cmdset_creation(self):
- """
- Called when the cmdset is created.
- """
- self.add(CmdMan())
- self.add(CmdUnman())
- class Console(SpaceObject):
- """
- The basic console object. This will need to be added to with mode CmdSets.
- """
- def at_object_creation(self):
- """
- Called when object is created. We make sure to set the needed
- Attribute and add the readable cmdset.
- """
- super(Readable, self).at_object_creation()
- self.db.operator = ""
- # define a command on the object.
- self.cmdset.add_default(CmdSetConsole, permanent=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement