Is it possible to manipulate string variables and have the resultant string point to an image?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
envixer
Newbie
Posts: 7
Joined: Tue Jan 09, 2018 2:21 pm
Contact:

Is it possible to manipulate string variables and have the resultant string point to an image?

#1 Post by envixer » Wed Jan 10, 2018 10:17 am

Ok, so after reading the title you're probably scratching your head.

As I mentioned in my first post, I'm using background images for all bgs and sprites, and I'm using sprite images for speech bubbles and exposition text. This means that with the right naming convention I should be able to have a single function display whole segments of the story.

So what I want to do is something like this:

While screencount > 0
image scenebg = "ch1" + screendisplay + ".png"
scene scenebg
pause 0.2
if loadable ("ch1" + screendisplay + "x1.png")
image expo1 = "ch1" + screendisplay + "x1.png"
show expo1
pause 0.2
if loadable ("ch1" + screendisplay + "t1.png")
image text1 = "ch1" + screendisplay + "t1.png"
show text1
pause
if loadable ("ch1" + screendisplay + "t2.png")
image text2 = "ch1" + screendisplay + "t2.png"
show text2
pause
screendisplay += 1
screencount -=1

Ok, so this snippet likely isn't accurate, but it's a high level description of what I'm trying to achieve. If I can loop this for each chapter, I'll be set because choices are only going to happen at the end of each chapter.

Any help is greatly appreciated!

User avatar
Remix
Eileen-Class Veteran
Posts: 1017
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 manipulate string variables and have the resultant string point to an image?

#2 Post by Remix » Wed Jan 10, 2018 10:55 am

Though it doesn't answer your entire question (the if loadable bits) you likely want to look at

default variable_name = "_variable_part"
image some_name = DynamicImage( "prefix[variable_name].png" )
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Finish Catmull-Rom Spline pathing
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

Post Reply

Who is online

Users browsing this forum: zeroTheHero