d7ec045a93fe0a9636ba9335caff0536349039e8
[mudpy.git] / bin / mudpy
1 #!/usr/bin/env python3
2 """Skeletal executable for the mudpy engine."""
3
4 # Copyright (c) 2004-2016 Jeremy Stanley <fungi@yuggoth.org>. Permission
5 # to use, copy, modify, and distribute this software is granted under
6 # terms provided in the LICENSE file distributed with this software.
7
8 # core objects for the mudpy engine
9 import imp
10 import os
11 import sys
12 sys.path.append(os.path.realpath("."))
13
14 import mudpy
15
16
17 def main():
18
19     # start it up
20     mudpy.misc.setup()
21
22     # loop indefinitely while the world is not flagged for termination or
23     # there are still connected users
24     while (not mudpy.misc.universe.terminate_flag or
25            mudpy.misc.universe.userlist):
26
27         # the world was flagged for a reload of all code/data
28         if mudpy.misc.universe.reload_flag:
29             imp.reload(mudpy)
30             mudpy.misc.reload_data()
31             mudpy.misc.universe.reload_flag = False
32
33         # do what needs to be done on each pulse
34         mudpy.misc.on_pulse()
35
36     # shut it all down
37     mudpy.misc.finish()
38
39
40 if __name__ == '__main__':
41     sys.exit(main())