Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. """
  2. Space Objects - Stephen 2017
  3.  
  4. This module holds all space objects
  5.  
  6. Objects:
  7.  
  8. SpaceObject
  9.  
  10. Console
  11. Ship
  12. Station
  13. Planet
  14. Nebula
  15. Debris
  16. """
  17. from future.utils import listvalues
  18.  
  19. import random
  20.  
  21. from evennia import DefaultObject, DefaultExit, Command, CmdSet
  22. from evennia import utils
  23. from evennia.utils import search
  24. from evennia.utils.spawner import spawn
  25.  
  26. #------------------------------------------------------------
  27. #
  28. # SpaceObject
  29. #
  30. # The SpaceObject is the base class for all items
  31. # in the space system.
  32. #
  33. # SpaceObjects may also be "reset". What the reset means
  34. # is up to the object.
  35.  
  36. #------------------------------------------------------------
  37.  
  38.  
  39. class SpaceObject(DefaultObject):
  40. """
  41. This is the baseclass for all objects in the space system.
  42. """
  43.  
  44. def at_object_creation(self):
  45. "Called when the object is first created."
  46. super(SpaceObject, self).at_object_creation()
  47. self.caller.msg("DEBUG -- " + self + " added to space system.")
  48. #evennia.search_channel("Space").msg(self + " added to space system by " + caller + ".")
  49.  
  50. def reset(self):
  51. "Resets the object, whatever that may mean."
  52. self.location = self.home
  53.  
  54.  
  55. #------------------------------------------------------------
  56. #
  57. # Console - an object that can be manned to control
  58. # space objects: 'man <console>'
  59. #
  60. #------------------------------------------------------------
  61.  
  62. #
  63. # man command
  64. #
  65.  
  66. class CmdMan(Command):
  67. """
  68. Usage:
  69. man [obj]
  70.  
  71. Man a mannable console.
  72. """
  73.  
  74. key = "man"
  75. locks = "cmd:all()"
  76. help_category = "Console"
  77.  
  78. def func(self):
  79. """
  80. Implements the man command.
  81. """
  82.  
  83. if self.args:
  84. obj = self.caller.search(self.args.strip())
  85. else:
  86. obj = self.obj
  87. if not obj:
  88. return
  89. string = "You can't man %s until the code is complete :)." % obj.key
  90. self.caller.msg(string)
  91.  
  92. class CmdMan(Command):
  93. """
  94. Usage:
  95. man [obj]
  96.  
  97. Man a mannable console.
  98. """
  99.  
  100. key = "man"
  101. locks = "cmd:all()"
  102. help_category = "Console"
  103.  
  104. def func(self):
  105. """
  106. Implements the unman command.
  107. """
  108.  
  109. if self.args:
  110. obj = self.caller.search(self.args.strip())
  111. else:
  112. obj = self.obj
  113. if not obj:
  114. return
  115. string = "You can't unman %s until the code is complete :)." % obj.key
  116. self.caller.msg(string)
  117.  
  118. class CmdSetConsole(CmdSet):
  119. """
  120. A CmdSet for consoles.
  121. """
  122. def at_cmdset_creation(self):
  123. """
  124. Called when the cmdset is created.
  125. """
  126. self.add(CmdMan())
  127. self.add(CmdUnman())
  128.  
  129.  
  130. class Console(SpaceObject):
  131. """
  132. The basic console object. This will need to be added to with mode CmdSets.
  133. """
  134. def at_object_creation(self):
  135. """
  136. Called when object is created. We make sure to set the needed
  137. Attribute and add the readable cmdset.
  138. """
  139. super(Readable, self).at_object_creation()
  140. self.db.operator = ""
  141. # define a command on the object.
  142. self.cmdset.add_default(CmdSetConsole, permanent=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement