Project

Profile

Help

Revision a5c338e8

Added by Vincent Le Goff almost 4 years ago

Put the macros and triggers in the world itself

View differences:

src/world.py
44 44

  
45 45
    def __init__(self, location):
46 46
        self.location = location
47
        self.settings = None
48 47
        self.name = ""
49 48
        self.hostname = ""
50 49
        self.port = 4000
51 50
        self.characters = {}
51
        self.settings = None
52

  
53
        # World's access to general data
54
        self.client = None
55
        self.engine = None
56
        self.sharp_engine = None
57

  
58
        # World's configuration
59
        self.macros = []
60
        self.triggers = []
52 61

  
53 62
    def __repr__(self):
54 63
        return "<World {} (hostname={}, port={})>".format(
......
58 67
    def path(self):
59 68
        return "worlds/" + self.location
60 69

  
70
    def load(self):
71
        """Load the config.set script."""
72
        from game import Level
73
        level = self.engine.level
74
        self.engine.level = Level.world
75
        path = self.path
76
        path = os.path.join(path, "config.set")
77
        if os.path.exists(path):
78
            file = open(path, "r")
79
            content = file.read()
80
            file.close()
81

  
82
            # Execute the script
83
            self.sharp_engine.execute(content)
84

  
85
        # Put the engine level back
86
        self.engine.level = level
87

  
61 88
    def save(self):
62
        """Save the world in its configuraiton file."""
89
        """Save the world in its configuration file."""
63 90
        if not os.path.exists(self.path):
64 91
            os.mkdir(self.path)
65 92

  

Also available in: Unified diff