Hello all. I need assistance parsing an XML file and passing the tags as variables to show different images. I am able to parse the tags in an XML file and store it in a variable. I want to then take that variable and show an image. In the example below, the xml has the tag background with the value Autumn_bg. I then store that in the variable background and try to pass that variable to the show command, but all I get is the default eileen background. I threw in the D "[background]" line just to confirm that the the variable is being stored properly. Any ideas how to pass a variable to show an image. I have tried a dozen different ways and its not working.
image Autumn_bg = im.Scale("Autumn_bg.jpg", 1920, 1080)
define D = Character("D")
label start:
python:
import xml.etree.ElementTree as ET
tree = ET.parse(renpy.loader.transfn("xml/test.xml"))
background = tree.find('background')
background = background.text
if background == "Autumn_bg":
show background
D "[background]"
return
Trouble passing variable to show command.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 2
- Joined: Sat Mar 11, 2023 4:28 pm
- Contact:
- Ocelot
- Lemma-Class Veteran
- Posts: 2445
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Trouble passing variable to show command.
show expression background as background
https://www.renpy.org/doc/html/displayi ... expression
https://www.renpy.org/doc/html/displayi ... expression
< < insert Rick Cook quote here > >
-
- Newbie
- Posts: 2
- Joined: Sat Mar 11, 2023 4:28 pm
- Contact:
Re: Trouble passing variable to show command.
Ocelot you are a genius. You have no idea how long I racked my brain trying to figure this out. Thank you so much.
Who is online
Users browsing this forum: Ahrefs [Bot]