Variable to access file
Posted: Thu Sep 23, 2021 10:50 am
I'm making a glossary and want to make textbuttons that change the character's picture. Atm I have a different set of buttons for each character but I'd like to make only 1 set for all of them. Just to tidy up.
It looks like this atm:
Boy is the character's name.
I made a class with the selectedCharacter variable and this is how I tried to 'automate' the whole thing. The first part works fine. What bricks it is finding the file.
""gui/custom/glossary/" + "selectedCharacter" + "_glossary1.webp"" just doesn't work. I also tried:
This is the error I get:
Would appreciate any clues or help.
It looks like this atm:
Code: Select all
textbutton "1" action SetVariable("boy.imageName", "gui/custom/glossary/boy_glossary1.webp")
textbutton "2" action SetVariable("boy.imageName", "gui/custom/glossary/boy_glossary2.webp")
I made a class with the selectedCharacter variable and this is how I tried to 'automate' the whole thing. The first part works fine. What bricks it is finding the file.
Code: Select all
textbutton "1" action SetVariable("selectedCharacter.imageName", "gui/custom/glossary/" + "selectedCharacter" + "_glossary1.webp")
Code: Select all
"gui/custom/glossary/" + "[selectedCharacter]" + "_glossary1.webp"
"gui/custom/glossary/" + selectedCharacter + "_glossary1.webp"
Code: Select all
File "renpy/display/image.py", line 577, in _scope
return self.find_target(scope, update)
File "renpy/display/image.py", line 652, in find_target
raise Exception(error)
Exception: DynamicImage u'[selectedCharacter.imageName]': could not find image. (u'gui/custom/glossary/selectedCharacter_glossary1.webp')