Ignore:
Timestamp:
06/23/09 17:13:48 (10 years ago)
Author:
bretzel_parpg
Message:

You can now select the file you want to save to or load from. filebrowser.py is actually
built into FIFE, but I copied it to the scripts folder because I had to make some
modifications to it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/scripts/engine.py

    r156 r162  
    1717 
    1818# there should be NO references to FIFE here! 
    19 import pickle 
     19import pickle, sys 
    2020from agents.hero import Hero 
    2121from agents.npc import NPC 
     
    6767        self.doors = {} 
    6868 
    69     def save(self, filename): 
     69    def save(self, path, filename): 
    7070        """Writes the saver to a file. 
    7171           @type filename: string 
     
    7373           @return: None""" 
    7474        self.updateGameState() 
     75        fname = '/'.join([path,filename]) 
    7576        try: 
    76             f = open(filename, 'r') 
     77            f = open(fname, 'w') 
    7778        except(IOError): 
    7879            sys.stderr.write("Error: Can't find save game\n") 
     
    8384        f.close() 
    8485 
    85     def load(self, filename): 
     86    def load(self, path, filename): 
    8687        """Loads a saver from a file. 
    8788           @type filename: string 
    8889           @param filename: the name of the file to load from 
    8990           @return: None""" 
     91        fname = '/'.join([path, filename]) 
    9092        try: 
    91             f = open(filename, 'r') 
     93            f = open(fname, 'r') 
    9294        except(IOError): 
    9395            sys.stderr.write("Error: Can't find save game file\n") 
     
    9799        self.currentMap = pickle.load(f) 
    98100        f.close() 
    99         if self.gameState.currentMap: 
    100             self.loadMap(self.gameState.currentMap) 
     101        if self.currentMap: 
     102            self.loadMap(self.currentMap) 
    101103             
    102104    def updateGameState(self): 
Note: See TracChangeset for help on using the changeset viewer.