Advertisement
Kovitikus

Global Script Won't Load

Sep 7th, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.49 KB | None | 0 0
  1. r"""
  2. Evennia settings file.
  3.  
  4. The available options are found in the default settings file found
  5. here:
  6.  
  7. d:\muddev\evennia\evennia\settings_default.py
  8.  
  9. Remember:
  10.  
  11. Don't copy more from the default file than you actually intend to
  12. change; this will make sure that you don't overload upstream updates
  13. unnecessarily.
  14.  
  15. When changing a setting requiring a file system path (like
  16. path/to/actual/file.py), use GAME_DIR and EVENNIA_DIR to reference
  17. your game folder and the Evennia library folders respectively. Python
  18. paths (path.to.module) should be given relative to the game's root
  19. folder (typeclasses.foo) whereas paths within the Evennia library
  20. needs to be given explicitly (evennia.foo).
  21.  
  22. If you want to share your game dir, including its settings, you can
  23. put secret game- or server-specific settings in secret_settings.py.
  24.  
  25. """
  26.  
  27. # Use the defaults from Evennia unless explicitly overridden
  28. from evennia.settings_default import *
  29.  
  30. ######################################################################
  31. # Evennia base server config
  32. ######################################################################
  33.  
  34. # This is the name of your game. Make it catchy!
  35. SERVERNAME = "Hecate"
  36. GAME_SLOGAN = "This is where the fun begins."
  37. SEARCH_MULTIMATCH_REGEX = r"(?P<number>[0-9]+) (?P<name>.*)"
  38. SEARCH_MULTIMATCH_TEMPLATE = " {number} {name}{aliases}{info}\n"
  39.  
  40. ######################################################################
  41. # Game Time setup
  42. ######################################################################
  43.  
  44. # You don't actually have to use this, but it affects the routines in
  45. # evennia.utils.gametime.py and allows for a convenient measure to
  46. # determine the current in-game time. You can of course interpret
  47. # "week", "month" etc as your own in-game time units as desired.
  48.  
  49. # The time factor dictates if the game world runs faster (timefactor>1)
  50. # or slower (timefactor<1) than the real world.
  51. TIME_FACTOR = 1.0
  52. # The starting point of your game time (the epoch), in seconds.
  53. # In Python a value of 0 means Jan 1 1970 (use negatives for earlier
  54. # start date). This will affect the returns from the utils.gametime
  55. # module. If None, the server's first start-time is used as the epoch.
  56. TIME_GAME_EPOCH = None
  57. # Normally, game time will only increase when the server runs. If this is True,
  58. # game time will not pause when the server reloads or goes offline. This setting
  59. # together with a time factor of 1 should keep the game in sync with
  60. # the real time (add a different epoch to shift time)
  61. TIME_IGNORE_DOWNTIMES = True
  62.  
  63. WEBCLIENT_OPTIONS = {
  64.     "gagprompt": True,  # Gags prompt from the output window and keep them
  65.     # together with the input bar
  66.     "helppopup": False,  # Shows help files in a new popup window
  67.     "notification_popup": False,  # Shows notifications of new messages as
  68.     # popup windows
  69.     "notification_sound": False   # Plays a sound for notifications of new
  70.     # messages
  71. }
  72.  
  73. ######################################################################
  74. # Global Scripts
  75. ######################################################################
  76.  
  77. # Global scripts started here will be available through
  78. # 'evennia.GLOBAL_SCRIPTS.key'. The scripts will survive a reload and be
  79. # recreated automatically if deleted. Each entry must have the script keys,
  80. # whereas all other fields in the specification are optional. If 'typeclass' is
  81. # not given, BASE_SCRIPT_TYPECLASS will be assumed.  Note that if you change
  82. # typeclass for the same key, a new Script will replace the old one on
  83. # `evennia.GLOBAL_SCRIPTS`.
  84. GLOBAL_SCRIPTS = {
  85.     # 'key': {'typeclass': 'typeclass.path.here',
  86.     #         'repeats': -1, 'interval': 50, 'desc': 'Example script'},
  87.     'time_cycle': {
  88.         'typeclass': 'time_cycle.TimeCycle',
  89.         'repeats': -1,
  90.         'interval': 1,
  91.         'desc': 'Tracks global timed events.',
  92.         'persistent': True
  93.     }
  94. }
  95.  
  96.  
  97. ######################################################################
  98. # Settings given in secret_settings.py override those in this file.
  99. ######################################################################
  100. try:
  101.     from server.conf.secret_settings import *
  102. except ImportError:
  103.     print("secret_settings.py file not found or failed to import.")
  104.  
  105.  
  106.  
  107. """typeclasses.time_cycle.py"""
  108. import datetime
  109.  
  110. from typeclasses.scripts import Script
  111. from typeclasses.rooms import Room
  112.  
  113. class TimeCycle(Script):
  114.     def at_script_creation(self):
  115.         self.key = 'time_cycle'
  116.         self.desc = "Tracks global timed events."
  117.         self.interval = 1
  118.         self.persistent = True
  119.  
  120.     def at_repeat(self):
  121.         now = datetime.datetime.now()
  122.         cur_hour = now.hour
  123.         cur_min = now.minute
  124.         cur_sec = now.second
  125.         if cur_sec != 0:
  126.             return
  127.         if cur_min not in [0, 20, 40]:
  128.             return
  129.  
  130.         # Daytime begins.
  131.         if cur_hour in [2, 6, 10, 14, 18, 22]:
  132.             if cur_min == 0:
  133.                 # Phase 1
  134.                 string = "The sun rises above the eastern horizon."
  135.             elif cur_min == 20:
  136.                 # Phase 2
  137.                 string = "It's now mid-morning."
  138.             elif cur_min == 40:
  139.                 # Phase 3
  140.                 string = "It's now early-noon."
  141.         elif cur_hour in [3, 7, 11, 15, 19, 23]:
  142.             if cur_min == 0:
  143.                 # Phase 4
  144.                 string = "It's now high-noon."
  145.             elif cur_min == 20:
  146.                 # Phase 5
  147.                 string = "It's now mid-afternoon."
  148.             elif cur_min == 40:
  149.                 # Phase 6
  150.                 string = "It's now dusk."
  151.         # Nighttime begins.
  152.         elif cur_hour in [0, 4, 8, 12, 16, 20]:
  153.             if cur_min == 0:
  154.                 # Phase 1
  155.                 string = "The sun has set and the moon begins to glow."
  156.             elif cur_min == 20:
  157.                 # Phase 2
  158.                 string = "It's now early-evening."
  159.             elif cur_min == 40:
  160.                 # Phase 3
  161.                 string = "It's now late-evening."
  162.         elif cur_hour in [1, 5, 9, 13, 17, 21]:
  163.             if cur_min == 0:
  164.                 # Phase 4
  165.                 string = "It's now midnight."
  166.             elif cur_min == 20:
  167.                 # Phase 5
  168.                 string = "It's now early-morning."
  169.             elif cur_min == 40:
  170.                 # Phase 6
  171.                 string = "The break of dawn approaches."
  172.         # Send out the string to all rooms.
  173.         for room in Room.objects.all():
  174.             room.msg_contents(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement