Help with the new image gallery: events, persistence, thumbn

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
rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Help with the new image gallery: events, persistence, thumbn

#1 Post by rocket »

Two questions as I add the last features to my little proof of cocnpet project. I suspect like many other of my questions they are fairly obvious but I've been staring at this so long things are starting to get blurry:

1. I want to reuse my artwork as the thumbnail for the gallery(why add another resource?) so I figure I need to do this:

Code: Select all

    image bg bridge normal ="images/bridge.png"
    image tb bridge = im.Scale("bg bridge normal",155,112)

# Later...
       g.page("Backgrounds")
        # Our first button is a picture of the bridge where you first met.
        g.button("tb bridge")
        g.unlock_image("bg bridge normal")
        # This shows a displayable...
        g.display("bg bridge normal")
        # ... if all prior images have been shown.
        g.allprior()
But when I call the gallery I get the following:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

Exception: Couldn't find file 'tb bridge'.

While running game code:
 - script at line 244 of /Applications/Games/renpy-6.3.1/Starlight/game/script.rpy
 - python at line 322 of /Applications/Games/renpy-6.3.1/Starlight/game/script.rpy.
 - python at line 256 of /Applications/Games/renpy-6.3.1/Starlight/game/new_gallery.rpy.

-- Full Traceback ------------------------------------------------------------

  File "/Applications/Games/renpy-6.3.1/renpy/bootstrap.py", line 204, in bootstrap
  File "/Applications/Games/renpy-6.3.1/renpy/main.py", line 303, in main
  File "/Applications/Games/renpy-6.3.1/renpy/main.py", line 98, in run
  File "/Applications/Games/renpy-6.3.1/renpy/execution.py", line 194, in run
  File "/Applications/Games/renpy-6.3.1/renpy/ast.py", line 491, in execute
  File "/Applications/Games/renpy-6.3.1/renpy/python.py", line 860, in py_exec_bytecode
  File "/Applications/Games/renpy-6.3.1/Starlight/game/script.rpy", line 322, in <module>
  File "/Applications/Games/renpy-6.3.1/Starlight/game/new_gallery.rpy", line 256, in show
  File "/Applications/Games/renpy-6.3.1/renpy/ui.py", line 66, in interact
  File "/Applications/Games/renpy-6.3.1/renpy/display/core.py", line 1237, in interact
  File "/Applications/Games/renpy-6.3.1/renpy/display/core.py", line 1354, in interact_core
  File "/Applications/Games/renpy-6.3.1/renpy/display/core.py", line 236, in predict
  File "/Applications/Games/renpy-6.3.1/renpy/display/core.py", line 210, in visit_all
  File "/Applications/Games/renpy-6.3.1/renpy/display/core.py", line 236, in <lambda>
  File "/Applications/Games/renpy-6.3.1/renpy/display/im.py", line 324, in predict_one
  File "/Applications/Games/renpy-6.3.1/renpy/display/im.py", line 127, in get
  File "/Applications/Games/renpy-6.3.1/renpy/display/im.py", line 351, in load
  File "/Applications/Games/renpy-6.3.1/renpy/loader.py", line 241, in load
Exception: Couldn't find file 'tb bridge'.

While running game code:

Ren'Py Version: Ren'Py 6.3.1b
I works if I pass it a file (defeating my purpouse), but not an image. What gives? I thought the function was supposed to take a displayable - which as I understand an image should be? Heck its the same for the 'success' displayable.

2. Dumb question 2. Why do my images show up unlocked before I start the game? Obviously the state of what has been shown is somehow persistent. But where/how is it set so I can clear it during development?

I'm guessing it has something to do with "persistent._seen_images" How is this stored (so I can write a button to clear it)? Also would there be name space conflicts?

Thanks again for your patience!

Free Time Machine
Regular
Posts: 42
Joined: Fri Jun 15, 2007 9:45 am
Location: Philly, USA
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#2 Post by Free Time Machine »

For #2, don't you want to just delete "persistent" from your save folder? (Sorry, I didn't really understand the specifics of your question...)
"HOLD ON TIGHT" ~ Outfits and expressions, where art thou? And why does Elsa's face look so awful??? *bangs head in*

Everytime you delete a traceback, someone else gets it. -PyTom

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#3 Post by PyTom »

You can't refer to image names when displayables are expected, you have to use the filename directly. I'd write your code as:

Code: Select all

    image bg bridge normal ="images/bridge.png"
# Later...
        g.page("Backgrounds")
        # Our first button is a picture of the bridge where you first met.
        g.button(im.Scale("images/bridge.png",155,112))
        g.unlock_image("bg bridge normal")
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#4 Post by rocket »

Free Time Machine wrote: For #2, don't you want to just delete "persistent" from your save folder? (Sorry, I didn't really understand the specifics of your question...)
See that's what I meant about something obvious... (^_^);;
For some reason I thought it was in a global or hidden location...
PyTom wrote:You can't refer to image names when displayables are expected, you have to use the filename directly. I'd write your code
:-/ Shucks, that's a bummer.
May I ask if there's a deep architectural reason for that, or if it is something that could be added as a new feature in a (far) future release?

What's wacky is that when I use that code my image is pinned to the upper left corner of the screen, not aligned with the button. Any number of images I do that way all end up stacked at 0,0. Seems like when I call Gallery.button() with a function it ends up expecting other arguments, or maybe im.Scale is in some way returning an absolute position value that is overriding the expected "no position" from an filename reference and this screwing up the relative layout. Any ideas?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#5 Post by PyTom »

rocket wrote: :-/ Shucks, that's a bummer.
May I ask if there's a deep architectural reason for that, or if it is something that could be added as a new feature in a (far) future release?
In the next release, I'll make public ImageReference, where you can write:

ImageReference("eileen happy")

to read in the "eileen happy" image. I need to think about making this the default for a string, since it may be ambiguous with image filenames. Perhaps I can make it work when an image isn't loadable... but I'm not sure if it's worth it.


What's wacky is that when I use that code my image is pinned to the upper left corner of the screen, not aligned with the button. Any number of images I do that way all end up stacked at 0,0. Seems like when I call Gallery.button() with a function it ends up expecting other arguments, or maybe im.Scale is in some way returning an absolute position value that is overriding the expected "no position" from an filename reference and this screwing up the relative layout. Any ideas?
Did you forget to call g.grid_layout, to let the new gallery code know how to arrange the buttons? Sounds like this might be the case.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#6 Post by rocket »

PyTom wrote: In the next release, I'll make public ImageReference, where you can write:
ImageReference("eileen happy")
W00t!
Awesome. I can see the attraction of the string default (more natural language), but this function takes care of the more critical need - indirection from the file name.
/me does the happy Ren'Py dance!
PyTom wrote: Did you forget to call g.grid_layout, to let the new gallery code know how to arrange the buttons? Sounds like this might be the case.
I called it.
Actually I'm just using the code example from the cookbook section as my framework while I learned the functions.
Like I said it works if I use the vanilla filename, but sticks to 0,0 if I use im.Scale.
:-/

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#7 Post by rocket »

While I'm at it:

1. What if my unlocked graphic is larger (or smaller) than the screen. I assume I can use some parameters for placement. Maybe wrap the image in a Pan function?

2. When passing multiple images to g.unlock_image(), is there a limit to how many I can pass as dependents? I assumed the first image would be the one displayed but when I tried with a triple set of images it would show the same image twice regardless of whether it was passed as the first or second argument (oddly when passed as the third it showed a different image). Sorry but there's not specific documentation there yet so I may be foolishly confused.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#8 Post by PyTom »

I need to investigate why im.Scale doesn't work. It's not really supported, in any case... my strong recommendation is to make thumbnail images, since they can be scaled properly with an image program. (Ren'Py's built in scaling is somewhat broken when scaling things smaller than .5 of the original size.)

By default, images smaller than the screen are centered on the bottom of the screen. You can probably change that with Position, but you can't use unlock_image, you'd probably need to use display and unlock, and use the displayable rather than the image name.

unlock_image works for me with multiple arguments. Are you showing things in the wrong order, so that the background is on top of the character?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: Help with the new image gallery: events, persistence, thumbn

#9 Post by rocket »

PyTom wrote:I need to investigate why im.Scale doesn't work. It's not really supported, in any case... my strong recommendation is to make thumbnail images, since they can be scaled properly with an image program. (Ren'Py's built in scaling is somewhat broken when scaling things smaller than .5 of the original size.)

By default, images smaller than the screen are centered on the bottom of the screen. You can probably change that with Position, but you can't use unlock_image, you'd probably need to use display and unlock, and use the displayable rather than the image name.
Got it. I'll try the manual displayables, but I think I should be fine.
unlock_image works for me with multiple arguments. Are you showing things in the wrong order, so that the background is on top of the character?
Disregard that. I misunderstood the intended usage. I thought:
unlock(image1,image2) == show image 1 if image 1 and image 2 have been shown in the past.

Instead it is (obvious to me now):
unlock(image1,image2) == show image 1 and image two combined if image 1 and image 2 have been shown in the past. Z-sort will be determined by order of arguments (last == top)

Thanks again!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]