- def write(f, msg):
- f.write(msg + '\n')
-
- with open(self.io.save_file, 'w') as f:
- write(f, 'TURN %s' % self.turn)
- map_geometry_shape = self.get_map_geometry_shape()
- write(f, 'MAP %s %s' % (map_geometry_shape, self.map_geometry.size,))
- for big_yx in [yx for yx in self.maps if self.maps[yx].modified]:
- for y, line in self.maps[big_yx].lines():
- write(f, 'MAP_LINE %s %5s %s' % (big_yx, y, quote(line)))
- for big_yx in self.annotations:
- for little_yx in self.annotations[big_yx]:
- write(f, 'GOD_ANNOTATE %s %s %s' %
- (big_yx, little_yx, quote(self.annotations[big_yx][little_yx])))
- for big_yx in self.portals:
- for little_yx in self.portals[big_yx]:
- write(f, 'GOD_PORTAL %s %s %s' % (big_yx, little_yx,
- quote(self.portals[big_yx][little_yx])))
- for big_yx in [yx for yx in self.map_controls
- if self.map_controls[yx].modified]:
- for y, line in self.map_controls[big_yx].lines():
- write(f, 'MAP_CONTROL_LINE %s %5s %s' % (big_yx, y, quote(line)))
- for tile_class in self.map_control_passwords:
- write(f, 'MAP_CONTROL_PW %s %s' % (tile_class,
- self.map_control_passwords[tile_class]))
- for t in [t for t in self.things if not t.type_ == 'Player']:
- write(f, 'THING %s %s %s %s' % (t.position[0],
- t.position[1], t.type_, t.id_))
- if hasattr(t, 'name'):
- write(f, 'THING_NAME %s %s' % (t.id_, quote(t.name)))
+ def write(f, msg):
+ f.write(msg + '\n')
+
+ with open(self.io.save_file, 'w') as f:
+ write(f, 'TURN %s' % self.turn)
+ map_geometry_shape = self.get_map_geometry_shape()
+ write(f, 'MAP %s %s' % (map_geometry_shape, self.map_geometry.size,))
+ for terrain in self.terrains.values():
+ write(f, 'TERRAIN %s %s %s %s %s' % (quote(terrain.character),
+ quote(terrain.description),
+ int(terrain.blocks_light),
+ int(terrain.blocks_sound),
+ int(terrain.blocks_movement)))
+ if len(terrain.tags) > 0:
+ for tag in terrain.tags:
+ write(f, 'TERRAIN_TAG %s %s' % (quote(terrain.character),
+ quote(tag)))
+ for big_yx in [yx for yx in self.maps if self.maps[yx].modified]:
+ for y, line in self.maps[big_yx].lines():
+ write(f, 'MAP_LINE %s %5s %s' % (big_yx, y, quote(line)))
+ for big_yx in self.annotations:
+ for little_yx in self.annotations[big_yx]:
+ write(f, 'GOD_ANNOTATE %s %s %s' %
+ (big_yx, little_yx, quote(self.annotations[big_yx][little_yx])))
+ for big_yx in self.portals:
+ for little_yx in self.portals[big_yx]:
+ write(f, 'GOD_PORTAL %s %s %s' % (big_yx, little_yx,
+ quote(self.portals[big_yx][little_yx])))
+ for big_yx in [yx for yx in self.map_controls
+ if self.map_controls[yx].modified]:
+ for y, line in self.map_controls[big_yx].lines():
+ write(f, 'MAP_CONTROL_LINE %s %5s %s' % (big_yx, y, quote(line)))
+ for tile_class in self.map_control_passwords:
+ write(f, 'MAP_CONTROL_PW %s %s' % (tile_class,
+ self.map_control_passwords[tile_class]))
+ for pw in self.admin_passwords:
+ write(f, 'ADMIN_PASSWORD %s' % pw)
+ for name in self.faces:
+ write(f, 'GOD_PLAYER_FACE %s %s' % (quote(name),
+ quote(self.faces[name])))
+ for name in self.hats:
+ write(f, 'GOD_PLAYER_HAT %s %s' % (quote(name),
+ quote(self.hats[name])))
+ for name in self.players_hat_chars:
+ write(f, 'GOD_PLAYERS_HAT_CHARS %s %s' %
+ (quote(name), quote(self.players_hat_chars[name])))
+ for t in [t for t in self.things if not t.type_ == 'Player']:
+ write(f, 'THING %s %s %s %s' % (t.position[0],
+ t.position[1], t.type_, t.id_))
+ write(f, 'GOD_THING_PROTECTION %s %s' % (t.id_, quote(t.protection)))
+ if hasattr(t, 'name'):
+ write(f, 'GOD_THING_NAME %s %s' % (t.id_, quote(t.name)))
+ if hasattr(t, 'installable') and (not t.portable):
+ write(f, 'THING_INSTALLED %s' % t.id_)
+ if t.type_ == 'Door' and t.blocks_movement:
+ write(f, 'THING_DOOR_CLOSED %s %s' % (t.id_, int(t.locked)))
+ elif t.type_ == 'Hat':
+ write(f, 'THING_HAT_DESIGN %s %s' % (t.id_,
+ quote(t.design)))
+ elif t.type_ == 'MusicPlayer':
+ write(f, 'THING_MUSICPLAYER_SETTINGS %s %s %s %s' %
+ (t.id_, int(t.playing), t.playlist_index, int(t.repeat)))
+ for item in t.playlist:
+ write(f, 'THING_MUSICPLAYER_PLAYLIST_ITEM %s %s %s' %
+ (t.id_, quote(item[0]), item[1]))
+ elif t.type_ == 'Bottle' and not t.full:
+ write(f, 'THING_BOTTLE_EMPTY %s' % t.id_)
+ elif t.type_ == 'DoorKey':
+ write(f, 'THING_DOOR_KEY %s %s' % (t.id_, t.door.id_))
+ write(f, 'SPAWN_POINT %s %s' % (self.spawn_point[0],
+ self.spawn_point[1]))