kakaroto/R20Converter

TypeError when selecting door color while converting scene

Closed this issue · 3 comments

$ cat src/version.py
version = "0.13.1"

$ python src/main.py --interactive ../MyCampaign/ ../MyCampaign.zip
...
Creating Scene : Lonelywood Elven Tomb
Background does not match scene dimensions 100%. Will be set as a tile instead
Unable to create thumbnail : cannot write mode RGBA as JPEG
In the page, walls are available in these colors :
1: #00ff00 (110 lines)
2: #ff00ff (6 lines)

Select which color is a door (0 for none) : 2
'dict_keys' object is not subscriptable
Traceback (most recent call last):
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/main.py", line 117, in <module>
    converter.convert()
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/R20Converter.py", line 222, in convert
    self.scenes = Scenes(self).save()
                  ^^^^^^^^^^^^
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/entities/scenes.py", line 21, in __init__
    self.entities = self.genEntities()
                    ^^^^^^^^^^^^^^^^^^
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/entities/scenes.py", line 32, in genEntities
    return [Scene(self, page, index, self._campaign["playerpageid"]) for index, page in enumerate(self._pages)]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/entities/scenes.py", line 32, in <listcomp>
    return [Scene(self, page, index, self._campaign["playerpageid"]) for index, page in enumerate(self._pages)]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/luke/code/r20converter/R20Converter-0.13.1-linux/src/entities/scenes.py", line 198, in __init__
    door_color = wall_colors.keys()[choice-1]
                 ~~~~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: 'dict_keys' object is not subscriptable
Error converting campaign with R20Converter v0.13.1:
'dict_keys' object is not subscriptable
Please contact the author with the log of the error from the console window

Here's one way to fix it. Encrypted since I'm not sure how closely you protect your source. And because I wanted to dust off my gnupg skills. Decrypt using the key on your keybase.
0001-scenes-fix-wall-color-selection.patch.asc.txt

Thanks! Was just looking at this when your email popped, lol

Patch has been reviewed and merged without changed. I've also fixed the prompt asking for door instead of secret door.
Well done, and thanks again!