Can image path be variable[SOLVED]

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
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Can image path be variable[SOLVED]

#1 Post by Luxliev »

I've tried to use

Code: Select all

:
$ path = "images/logo_base.png"

image logo = "[path]"
Last edited by Luxliev on Sun Nov 15, 2015 2:14 pm, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: Can image path be variable

#2 Post by mobychan »

I believe simply using

Code: Select all

image logo = path
should work
"[variable]" is for using with "spoken" text

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Can image path be variable

#3 Post by Luxliev »

Oh I see thanks. Can I make it more dynamic? So it'll update if I'll change path? When I reload image currently it shows me same image as before:

Code: Select all

init python:
    path = "images/logo_base.png"

image logo = path

label start:
    show logo

    "1"

    hide logo

    $ path = "images/logo_mini.png"
   
    "2"

    show logo
    
    "3"
    
    return
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: Can image path be variable

#4 Post by mobychan »

did you simply try using

Code: Select all

show path
?

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Can image path be variable

#5 Post by Luxliev »

Doesn't work it just shows gray image with variable name (path)
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Can image path be variable

#6 Post by Alex »


User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Can image path be variable

#7 Post by nyaatrap »

Here is a modern way (6.99.7~) http://www.renpy.org/doc/html/displayab ... namicImage

Code: Select all

image dynamic_image = "[path].png"

Code: Select all

$path = "folder/name"
show dynamic_image
In 6.99.7, "path" is parsed as DynamicImage("path") when [] is included by default. Otherwise, it's parsed as Image("path")

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Can image path be variable

#8 Post by Luxliev »

Alex wrote:When try

Code: Select all

show expression path
http://www.renpy.org/doc/html/displayin ... -statement
nyaatrap wrote:Here is a modern way (6.99.7~) http://www.renpy.org/doc/html/displayab ... namicImage

Code: Select all

image dynamic_image = "[path].png"

Code: Select all

$path = "folder/name"
show dynamic_image
In 6.99.7, "path" is parsed as DynamicImage("path") when [] is included by default. Otherwise, it's parsed as Image("path")
Thank you both for answers they work great. Newest version of dynamic image works better because you don't have to show image again to see change. Here code for anyone to test themselves

Code: Select all

init python:
    path = "images/logo_base.png"

label start:
    show expression path

    "1"

    $ path = "images/logo_mini.png"
    
    "2"
    
    show expression path
    
    "3"
    
    return
And

Code: Select all

init python:
    path = "images/logo_base.png"

image dynamic_image = "[path]"

label start:
    show dynamic_image

    "1"

    $ path = "images/logo_mini.png"
    
    "2"
    
    return
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: No registered users