View Single Post
07-12-2007, 04:21 PM
#1
xZaft is offline xZaft
Status: Member
Join date: Jul 2005
Location: Massachusetts, US
Expertise:
Software:
 
Posts: 428
iTrader: 0 / 0%
 

xZaft is on a distinguished road

  Old  [Python] Working with a save function.

Code:
def save():
    try:
        saves.append(str(level))
        saves.append(str(stre))
        saves.append(str(spd))
        saves.append(str(hp))
        saves.append(str(maxhp))
        saves.append(str(exp))
        saves.append(str(maxexp))
        saves.append(str(gp))
        saves.append(str(sword))
        save = open('gamesave.txt', 'r+')
        for s in saves:
            save.write(s)
            save.write('\n')
            saves.remove(s)
            print s
        print "Save successful."
        save.close()
    except ValueError: print "Save unsuccessful."
This should append all of those values, all of which are numbers, into the saves list. Then it should open gamesave.txt, and write them into it, and remove them from the list one by one. As it goes through, only a few are actually sent through, and the last 4 are left.

The attachment shows this. The top line is the saves list. The numbers below it are the ones that are written to the text file.

Anyone know why it won't get all the way through the list?

Attached Images
File Type: jpg gamesave.jpg (18.2 KB, 9 views)