This is probably a very daft question, but I couldn't find an answer anywhere. Is it possible to use a variable as part of Ren'Py statements, and if yes, how? For example, say that I have five status images (status1.png ... status5.png), and at times during the game I wish to show one that matches the current "status" variable value (1-5). Is there a way to do something like this (the example is obviously non-functioning):
show status+$status.png
Hopefully I managed to explain this so that it makes sense, please ask if any clarification is needed.
[SOLVED] Is it possible to use variables in Ren'Py statements?
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.
[SOLVED] Is it possible to use variables in Ren'Py statements?
Last edited by vorgbardo on Tue Jun 25, 2019 8:44 am, edited 2 times in total.
A dyslexic man walks into a bra.
Re: Is it possible to use variables in Ren'Py statements?
show expression. https://www.renpy.org/doc/html/displayi ... -statement (you have to scroll down a bit to find show expression)
show expression "status"+status+".png"
show expression "status"+status+".png"
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Is it possible to use variables in Ren'Py statements?
You could alternatively define an image that interpolated the variable part in the name string:
Code: Select all
default current_status = 1
image status = "images/status[current_status].png"
label start:
show status
"..."
$ current_status = 2 # now showing status2.png automaticallyFrameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Is it possible to use variables in Ren'Py statements? [SOLVED]
Thank you kindly for the answers, worked perfectly!
Just in case someone has the exact same problem I had, as my status was an integer, I had to make it a string first to get it work with the first solution:
show expression "status"+str(status)+".png"
Just in case someone has the exact same problem I had, as my status was an integer, I had to make it a string first to get it work with the first solution:
show expression "status"+str(status)+".png"
A dyslexic man walks into a bra.
Who is online
Users browsing this forum: Google [Bot], _ticlock_