Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The issue here is that the images are being defined after the gallery is created, instead of before. To solve this, just add init -26 to the top of the definition file, i.e:

init -26:
    #Images
    ##Background
    image bg GrandmaHouse = "Background/Entrance.jpeg"
    image bg house = "Background/House.jpeg"
...etc.

Let me know if that works for you!

Thank you for the reply! It didn't work for me! Same issue ;; - ;;

Can you send me your kit_options rpy so I can take a look?

(2 edits)

kit_options.rpy

init -25:
    define gui.use_side_image = True
    define gallery.enabled = True
    # If true, items in the gallery will be unlocked based on variables and instead of automatically after the player has seen them
    define gallery.variable_mode = False
    #"GrandmaHouse", "house", "Woods", "DeepWood", "GrandmaEntrance", "GrandmaBedroom", "village"
    define gallery.items = []
    # If true, items in the gallery will only unlock once all items have been seen. Doesn't do anything if variable mode is on.
    define gallery.strict_multiple = False
    define music_room.enabled = True
    # If True, all tracks will be unlocked by default. If false, tracks will appear only once they are heard by the player.
    define music_room.unlocked = False
    define music_room.tracks = [
    {"name": "Don't Stray From The Road", "file": "OST/Don't Stray From The Road.mp3"},
    {"name": "Horror Ambience", "file": "OST/Horror Ambience.mp3"},
    {"name": "Miss Riding Hood", "file": "OST/Miss Riding Hood.mp3"},
    {"name": "The Way on The Woods", "file": "OST/The Way on The Woods.mp3"},
    {"name": "Hunting a Wolf Down", "file": "OST/Hunting a Wolf Down.mp3"},
    ]

Gallery.rpy

# Instant CG and BG Gallery by Leon: https://lemmasoft.renai.us/forums/viewtopic.php?f=51&t=22465 
init python:
    #list the CG gallery images here:
    gallery_thumbnails = []
    gal_rows = 3
    gal_cols = 2
    #Thumbnail size in pixels:
    thumbnail_x = 328
    thumbnail_y = 185
    
    gal_cells = gal_rows * gal_cols    
    g_cg = Gallery()
    if not gallery.variable_mode:
        for gal_item in gallery.items:
            if (isinstance(gal_item, list)):
                gallery_thumbnails.append(gal_item[0])
                g_cg.button(gal_item[0] + " butt")
                if gallery.strict_multiple:
                    g_cg.unlock_image(*gal_item)
                
                else:
                    for item in gal_item:
                        g_cg.unlock_image(item)
            else:
                gallery_thumbnails.append(gal_item)
                g_cg.button(gal_item + " butt")
                g_cg.unlock_image(gal_item)
    else: 
        for gal_item in gallery.items:
            if (isinstance(gal_item["image"], list)):
                gallery_thumbnails.append(gal_item["image"][0])
                g_cg.button(gal_item["image"][0] + " butt")
                g_cg.condition(gal_item["variable"])
                for item in gal_item["image"]:
                    g_cg.image(item)
            
            else:
                gallery_thumbnails.append(gal_item["image"])
                g_cg.button(gal_item["image"] + " butt")
                g_cg.condition(gal_item["variable"])
                g_cg.image(gal_item["image"])
                
            
    g_cg.transition = fade
    cg_page=0
    
init +1 python:
    #Here we create the thumbnails. 
    for gal_item in gallery_thumbnails:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
        
screen auto_gallery:
    tag menu
    use game_menu(_("Gallery")):
        $ current_num = cg_page + 1
        fixed:
            xpos -170
            if (len(gallery_thumbnails)>gal_cells):
                text "Page {}".format(current_num):
                    ypos 55
                    xalign 0.5
                    style "page_label_text"
            frame background None:
                xalign 0.5
                yalign 0.5
                grid gal_rows gal_cols:
                    xalign 0.5
                    yalign 0.5
                    spacing gui.slot_spacing
                    $ i = 0
                    $ next_cg_page = cg_page + 1
                    $ prev_cg_page = cg_page -1            
                    if next_cg_page > int(len(gallery_thumbnails)/gal_cells):
                        $ next_cg_page = 0
                    elif prev_cg_page == -1:
                        $ prev_cg_page = 0
                    for gal_item in gallery_thumbnails:
                        $ i += 1
                        if i <= (cg_page+1)*gal_cells and i>cg_page*gal_cells:
                            add g_cg.make_button(gal_item + " butt", gal_item + " butt","gui/gallery/locked.png", xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=24)
                    for j in range(i, (cg_page+1)*gal_cells): #we need this to fully fill the grid
                        null
                if (len(gallery_thumbnails)>gal_cells):
                    $ pages = ((len(gallery_thumbnails)) / gal_cells) + 1
                    hbox:
                        style_prefix "page"
                        xalign 0.5
                        yalign 0.96
                        spacing gui.page_spacing
                        imagebutton:
                            auto "gui/gallery/page_number_%s.png"
                            foreground Text(_("<"),style="pg_num_idle")
                            hover_foreground Text(_("<"),style="pg_num_hover") 
                            insensitive_foreground Text(_("<"),style="pg_num_insensitive")
                            action [SetVariable('cg_page', prev_cg_page), ShowMenu("auto_gallery")]
                            sensitive cg_page != 0
                        for num in range(pages):
                            $display_num = num + 1
                            imagebutton:
                                auto "gui/gallery/page_number_%s.png"
                                foreground Text(_("{}".format(display_num)), style="pg_num_idle")
                                hover_foreground Text(_("{}".format(display_num)), style="pg_num_hover")
                                action [SetVariable('cg_page', num), ShowMenu("auto_gallery")]
                        imagebutton:
                            auto "gui/gallery/page_number_%s.png"
                            foreground Text(_(">"),style="pg_num_idle")
                            hover_foreground Text(_(">"),style="pg_num_hover")
                            insensitive_foreground Text(_(">"),style="pg_num_insensitive")
                            action [SetVariable('cg_page', next_cg_page), ShowMenu("auto_gallery")]
                            sensitive cg_page != pages-1

Did you ever get this fixed? I am having the same issue.

Hello, same problem and same error here.
The short question is: how do we add images that are inside a "sub folder" of the "images" folder?

e.g. 
If a image "classroom.png" is in the "/images/" folder, I can add it to the gallery like this:
```
define gallery.items = ['classroom']
```

If a image "classroom.png" is in the "/images/background/" folder, I CANNOT add it to the gallery like this:

```
define gallery.items = ['background/classroom']

```

The latter will result in error.

If I tried to init the images first
```

init -26:
      image bg myClassroom:
             "images/background/classroom.png"

```
And then

```

define gallery.items = ['myClassroom']

```

It will result in the same error as Noa Tugy's was facing.