Code: Select all
init python:
dict1 = {}
dict2 = {}
dict1['testcase'] = 0
dict1.has_key('testcase')
Code: Select all
init python:
dict1 = {}
dict2 = {}
dict1['testcase'] = 0
dict1.has_key('testcase')
Code: Select all
init python:
import xml.etree.ElementTree as ET
import math
import renpy.store as store
import renpy.exports as renpy
...
earnedProgress = _dict()
def achievement(type, id, steps = 0): # it takes a string type, an int id, and an optional int steps
if "honor" in type.lower() or type.lower() == "moh" or type.lower() == "mofh": #if it's an honor...
...
else: #if it's a Mark of Progress, do the same thing, but replace earnedHonors with earnedProgress
#first get the achievement data, so we can use it
findPath = "MoP[@id='" + str(id) + "']"
print findPath #for debugging
achInfo = Achievements.find(findPath)
if earnedProgress.has_key(str(id)): #if we've seen this achievement before.. <<<<<THIS IS THE ERROR LINE
if earnedProgress[str(id)] != 0: #and we don't already have it...
earnedProgress[str(id)] += steps #increment it!
#now see if we've earned it or not
if earnedProgress[str(id)] >= int(archInfo.find("steps").text):
print "progress get!"
earnedProgress[str(id)] = 0 #we got it, so set it to 0 since we have it now
doActions(achInfo) #also run its actions
else: #if we do have it already, do nothing (expect debug code)
print "we already have MoP " + str(id) + "."
else: #we've never seen this one before. Add it to the dict and run it's actions
earnedProgress[ str(id) ] = steps
if earnedProgress[ str(id) ] == 0:
print "progress get!"
doActions(achInfo)
They are already imported... you have no idea how redicolous it is to import renpy into renpy, but I suppose it doesn't do anything weird either. Basically it's the same as putting:pucedragonlord wrote:Those renpy exports are to allow custom class objects to be saved properly.Code: Select all
init python: import renpy.store as store import renpy.exports as renpy
I'm thoroughly confused.
Code: Select all
# ABRAKADABRA HOOOAH!
Code: Select all
earnedProgress={}
raise Exception, type(earnedProgress)
Code: Select all
if str(id) in earnedProgress:
Code: Select all
if earnedProgress.has_key(str(id)):
Actually, 'in' works for lists. It's probably not very efficient, but it works. So this might actually fix it - more likely, it'll stop the error from appearing and cause problems elsewhere because earnedProgress still isn't a dict.xela wrote:PS:
Just for the record:
is better Python than:Code: Select all
if str(id) in earnedProgress:
but there is no chance that this will fix your errorCode: Select all
if earnedProgress.has_key(str(id)):
That's good to know, actually. I'll remember that.xela wrote:
Just for the record:
is better Python than:Code: Select all
if str(id) in earnedProgress:
but there is no chance that this will fix your errorCode: Select all
if earnedProgress.has_key(str(id)):
Code: Select all
from renpy.python import RevertableList as dict
Users browsing this forum: Google [Bot]