[SOLVED]ordered dict???
Posted: Thu Nov 25, 2021 9:09 pm
Hiya,
I lately noticed, that dict-variables inside of Ren'Py aren't ordered as they are in Python at least, they don't seem to work as they should. I've written a little game editor in Python (Python 3.10) that is using json files to exchange data between the editor and the Ren'Py game. To read the data in RenPy I am using json.loads which doesn't seem to have any problem. The problem only occurs when I read the dict with a loop something like:
I get it in a random order.
I also tried to check if the dict type inside of Ren'Py would be the problem or the json.reads but I couldn't even create a dict inside of Ren'Py instead of a dict I get a <class 'renpy.python.RevertableDict'> which also isn't ordered, so I am a bit clueless here. Is the only way really that I number and sort the dict inside of Ren'Py, because in Python it doesn't seem to have any problem to be given out in the same order as it got created?
I lately noticed, that dict-variables inside of Ren'Py aren't ordered as they are in Python at least, they don't seem to work as they should. I've written a little game editor in Python (Python 3.10) that is using json files to exchange data between the editor and the Ren'Py game. To read the data in RenPy I am using json.loads which doesn't seem to have any problem. The problem only occurs when I read the dict with a loop something like:
Code: Select all
python:
for i in dictTypeVar:
renpy.say(None, "element: [i])
I also tried to check if the dict type inside of Ren'Py would be the problem or the json.reads but I couldn't even create a dict inside of Ren'Py instead of a dict I get a <class 'renpy.python.RevertableDict'> which also isn't ordered, so I am a bit clueless here. Is the only way really that I number and sort the dict inside of Ren'Py, because in Python it doesn't seem to have any problem to be given out in the same order as it got created?