Instant CG and BG gallery

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#46 Post by leon » Fri Aug 23, 2013 8:17 am

Zebragirl wrote:The code works for me everything, but the images in the gallery are already unlocked,also your file has CG images already unlocked without i need view them before unlocking...
That's weird... Only one CG image should unlock in the example code, since others are never shown. Like here - http://lemmasoft.renai.us/forums/downlo ... &mode=view
Zebragirl wrote:I need that the images are all locked, and only after seeing them may appear in the gallery.
That's what this part should do:

Code: Select all

        g_cg.unlock(gal_item)
Documentation about the gallery and unlock - http://www.renpy.org/doc/html/rooms.html#Gallery.unlock

Try to Delete Persistent from Ren'Py launcher. If that doesn't work, try making a simple gallery without using the code here and ask about this in Ren'Py Questions and Announcements, if the problem persists.

User avatar
Zebragirl
Newbie
Posts: 8
Joined: Fri Apr 05, 2013 3:54 pm
Contact:

Re: Instant CG and BG gallery

#47 Post by Zebragirl » Fri Aug 23, 2013 8:36 am

leon wrote:
Zebragirl wrote:The code works for me everything, but the images in the gallery are already unlocked,also your file has CG images already unlocked without i need view them before unlocking...
That's weird... Only one CG image should unlock in the example code, since others are never shown. Like here - http://lemmasoft.renai.us/forums/downlo ... &mode=view
Zebragirl wrote:I need that the images are all locked, and only after seeing them may appear in the gallery.
That's what this part should do:

Code: Select all

        g_cg.unlock(gal_item)
Documentation about the gallery and unlock - http://www.renpy.org/doc/html/rooms.html#Gallery.unlock

Try to Delete Persistent from Ren'Py launcher. If that doesn't work, try making a simple gallery without using the code here and ask about this in Ren'Py Questions and Announcements, if the problem persists.

Hey really thanks for the reply!

Is solved with the Delete Persistent like you said,I suspected it was a problem from the luncher,but I did not know what it was Delete Persistent...

Well,thanks again for the help, now it works perfectly.
And thank you for your useful work!

monkeyartist214
Newbie
Posts: 12
Joined: Sun Jul 28, 2013 9:14 pm
Contact:

Re: Instant CG and BG gallery

#48 Post by monkeyartist214 » Sun Sep 01, 2013 12:07 am

Hi! I tried using your code, but for some reason, I keep getting this...

I'm sorry, but an uncaught exception occurred.

While executing init code:
File "game/screens.rpy", line 554, in script
init python:
Exception: Action is required in ui.key.


... every time I launch the game to check if it is working.

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#49 Post by leon » Sun Sep 01, 2013 6:58 am

Code: Select all

I'm sorry, but an uncaught exception occurred.

While executing init code:
  File "game/screens.rpy", line 554, in script
    init python:
Exception: Action is required in ui.key.
The error has nothing to with this code. ui.key is a Python equivalent of a screen language statement Key and neither is being used here. The error suggest, that you haven't defined an action that should run on some keypress... If you can't get it to work, ask in the Ren'Py Questions and Announcements section and don't forget to include the full traceback and the code where the error happens.

Vmarshal
Newbie
Posts: 2
Joined: Thu Oct 10, 2013 12:38 pm
Contact:

Re: Instant CG and BG gallery

#50 Post by Vmarshal » Thu Oct 10, 2013 12:45 pm

I did everything as instructed and fixed the hiccups in my code. One problem though, the images don't unlock.

I deleted saved data and persistent data and have tried playing through the VN thinking it will unlock after viewing all the images manually via VN. Still locked in the gallery. Don't know what's going on. Clicking on the 'locked images' didn't work either. Any help would be appreciated :(

Code: Select all

init:
    image cg1 = "Satsuki-Fellatio.jpg"
    image cg2 = "Satsuki-Cowgirl.jpg"
    image cg3 = "Satsuki-Cowgirl-Cum.jpg"
    image cg4 = "Vampire Cowgirl.jpg"
    image cg5 = "Vampire Cowgirl Cum.jpg"

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1", "cg2", "cg3", "cg4", "cg5"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 2
    #thumbnail size in pixels:
    thumbnail_x = 200
    thumbnail_y = 150
    #the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 or something else.
    #Galleries settings - end
    
    gal_cells = gal_rows * gal_cols    
    g_cg = Gallery()
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
    g_cg.transition = fade
    cg_page=0
    
init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
     
screen cg_gallery:
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_cg_page = cg_page + 1            
            if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                $ next_cg_page = 0
            for gal_item in gallery_cg_items:
                $ 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", im.Scale("gallocked.png", thumbnail_x, thumbnail_y), 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
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]

Vmarshal
Newbie
Posts: 2
Joined: Thu Oct 10, 2013 12:38 pm
Contact:

Re: Instant CG and BG gallery

#51 Post by Vmarshal » Fri Oct 11, 2013 10:51 am

Vmarshal wrote:I did everything as instructed and fixed the hiccups in my code. One problem though, the images don't unlock.

I deleted saved data and persistent data and have tried playing through the VN thinking it will unlock after viewing all the images manually via VN. Still locked in the gallery. Don't know what's going on. Clicking on the 'locked images' didn't work either. Any help would be appreciated :(

Code: Select all

init:
    image cg1 = "Satsuki-Fellatio.jpg"
    image cg2 = "Satsuki-Cowgirl.jpg"
    image cg3 = "Satsuki-Cowgirl-Cum.jpg"
    image cg4 = "Vampire Cowgirl.jpg"
    image cg5 = "Vampire Cowgirl Cum.jpg"

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1", "cg2", "cg3", "cg4", "cg5"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 2
    #thumbnail size in pixels:
    thumbnail_x = 200
    thumbnail_y = 150
    #the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 or something else.
    #Galleries settings - end
    
    gal_cells = gal_rows * gal_cols    
    g_cg = Gallery()
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
    g_cg.transition = fade
    cg_page=0
    
init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
     
screen cg_gallery:
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_cg_page = cg_page + 1            
            if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                $ next_cg_page = 0
            for gal_item in gallery_cg_items:
                $ 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", im.Scale("gallocked.png", thumbnail_x, thumbnail_y), 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
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]
I finally figured it out. The name of the CG images in screens.rpy has to be the same name as the ACTUAL CG image files in your scripts.rpy. The reason it didn't unlock was because renpy recognized the images as separate entities due to their tags being different. By renaming my original script files with the same tags as the screens.rpy init, the CG Gallery was able to unlock on the first instance it was displayed in-game.

User avatar
Kagehide
Regular
Posts: 34
Joined: Wed Oct 30, 2013 6:13 am
Projects: Heroine of Revenge
Location: The Netherlands
Contact:

Re: Instant CG and BG gallery

#52 Post by Kagehide » Mon Dec 23, 2013 4:42 pm

Hello, i am trying to get the bg gallery to work and until now i havent gotten any errors but the problem is that i am not able to access the bg gallery.
I dont know if there is already an button defined for it in the code or if i have to make one myself (and i have no idea how to).
I hope you'll be able to figure it out for me.
Here is how my gallery code looks like right now.

Code: Select all

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1", "cg3", "cg4", "cg5", "cg6", "cg7", "cg8", "cg9", "cg10", "cg11"]
    #list the BG gallery images here (if a BG includes several variations, such as night version, include only one variation here):
    gallery_bg_items = ["bg black", "bg forest", "bg campfnight", "bg campfire"]
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 2
    #thumbnail size in pixels:
    thumbnail_x = 230
    thumbnail_y = 150
    #the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 or something else.
    #Galleries settings - end
   
    gal_cells = gal_rows * gal_cols   
    g_cg = Gallery()
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
        if gal_item == "cg1":
            g_cg.image("cg2")
            g_cg.unlock("cg2")
    g_cg.transition = fade
    cg_page=0

    g_bg = Gallery()
    for gal_item in gallery_bg_items:
        g_bg.button(gal_item + " butt")
        g_bg.image(gal_item)
        g_bg.unlock(gal_item)
        #if BGs have variations, such as night version, uncomment the lines below and include the code for each BG with variations
        if gal_item == "bg campfnight":
            g_cg.image("bg campfire")
            g_cg.unlock("bg campfire")
    g_bg.transition = fade
    bg_page=0
   
init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
    for gal_item in gallery_bg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
        renpy.image (gal_item + " butt dis", im.Grayscale(ImageReference(gal_item + " butt")))
       
screen cg_gallery:
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_cg_page = cg_page + 1           
            if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                $ next_cg_page = 0
            for gal_item in gallery_cg_items:
                $ 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", im.Scale("gallocked.png", thumbnail_x, thumbnail_y), 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
        frame background None:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]

screen bg_gallery:
#The BG gallery screen is more or less copy pasted from the CG screen above, I only changed "make_button" to include a grayscale thumbnail for locked items
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_bg_page = bg_page + 1
            if next_bg_page > int(len(gallery_bg_items)/gal_cells):
                $ next_bg_page = 0
            for gal_item in gallery_bg_items:
                $ i += 1
                if i <= (bg_page+1)*gal_cells and i>bg_page*gal_cells:
                    add g_bg.make_button(gal_item + " butt", gal_item + " butt", gal_item + " butt dis", xalign=0.5, yalign=0.5, idle_border=None, background=None, bottom_margin=24)
            for j in range(i, (bg_page+1)*gal_cells):
                null
        frame:
            yalign 0.97
            vbox:
                if len(gallery_bg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('bg_page', next_bg_page), ShowMenu("bg_gallery")]
*Avatar by me*
"I’ve decided…I won’t run away any more…I’ll fight with my future! I’ll fight with the future that everyone’s made for me! Not for anyone else, but for myself!" -Hinata Hajime

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#53 Post by leon » Tue Dec 24, 2013 8:37 am

You need to add one or several buttons on the main menu (screen main_menu) in screens.rpy.

Code: Select all

#...
        textbutton _("Start Game") action Start()
        textbutton _("CG Gallery") action ShowMenu("cg_gallery")
        textbutton _("BG Gallery") action ShowMenu("bg_gallery")
        textbutton _("Load Game") action ShowMenu("load")
#...

User avatar
Hazel-Bun
Eileen-Class Veteran
Posts: 1008
Joined: Sun Oct 28, 2012 6:03 pm
Completed: Sunrise: A Dieselpunk Fantasy & Ultramarine: A Seapunk Adventure
Organization: AURELIA LEO, LLC
Location: Louisville, Kentucky
Contact:

Re: Instant CG and BG gallery

#54 Post by Hazel-Bun » Tue Dec 24, 2013 12:25 pm

Thank you so much for this code 0: I'll be using it today to try and make the images appear properly.

User avatar
Boniae
Regular
Posts: 186
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Re: Instant CG and BG gallery

#55 Post by Boniae » Tue Jan 28, 2014 2:37 pm

Thank you so much for this script! It's worked perfectly up until today though, I started adding in some new images and I've run into a problem...not sure what it is? As soon as my gallery gets to the second page it gives this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in script
  File "game/screens.rpy", line 729, in python
NameError: name 'clicked' is not defined

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

Full traceback:
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\ast.py", line 720, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\python.py", line 1304, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in <module>
    $ ui.interact()
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\core.py", line 1864, in interact
    scene_lists.replace_transient()
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\core.py", line 554, in replace_transient
    self.remove(layer, tag)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\core.py", line 828, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\core.py", line 752, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\screen.py", line 189, in _hide
    hid.update()
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\display\screen.py", line 266, in update
    self.screen.function(**self.scope)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\screenlang.py", line 1217, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "H:\DESKTOP\renpy-6.16.0-sdk\renpy\python.py", line 1304, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 729, in <module>
    $ ui.imagebutton ("UI/gallery1.png", "UI/gallery2.png", clicked [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")])
NameError: name 'clicked' is not defined
here's my gallery code:

Code: Select all

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["cg1", "cg2a", "cg3", "cg4", "cg5", "cg6", "cg7", "cg8a", "cg9a", "cg10"]
    
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 3
    
    #thumbnail size in pixels:
    thumbnail_x = 213
    thumbnail_y = 135
    
    #the setting above (267x150) will work well with 16:9 screen ratio. Make sure to adjust it, if your are using 4:3 or something else.
    #Galleries settings - end
    
    gal_cells = gal_rows * gal_cols    
    g_cg = Gallery()
    
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
        
        if gal_item == "cg1":
            g_cg.image("cg1b")
            g_cg.unlock("cg1b")
        if gal_item == "cg2a":
            g_cg.image("cg2b")
            g_cg.unlock("cg2b")
        if gal_item == "cg6":
            g_cg.image("cg6b")
            g_cg.unlock("cg6b")
        if gal_item == "cg8a":
            g_cg.image("cg8b")
            g_cg.unlock("cg8b")
        if gal_item == "cg9a":
            g_cg.image("cg9b")
            g_cg.unlock("cg9b")      
   
    
    g_cg.transition = fade
    cg_page=0
    
   
init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
        
screen cg_gallery:
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_cg_page = cg_page + 1            
            if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                $ next_cg_page = 0
            for gal_item in gallery_cg_items:
                $ 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", im.Scale("UI/gallocked.png", thumbnail_x, thumbnail_y), 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
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    $ ui.imagebutton ("UI/gallery1.png", "UI/gallery2.png", clicked [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")])
If you're able to help me out that'd be great. I have no idea what the problem is, especially since it was working before. I tried comparing it with my script before the edits and no luck.

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#56 Post by leon » Tue Jan 28, 2014 3:14 pm

It seems the error is referring to the last line where the button is. I think you need to use "clicked=..."? Or just use screen language.

User avatar
Boniae
Regular
Posts: 186
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Re: Instant CG and BG gallery

#57 Post by Boniae » Tue Jan 28, 2014 4:27 pm

Ah, would you look at that, it worked! :D (Jeez, its always the simple things) Thanks so much! :mrgreen:

User avatar
ppppantsu
Veteran
Posts: 226
Joined: Fri Jan 24, 2014 7:14 am
Completed: Haruman, DMMd Fan VN, Fetish 1.0, Fetish: ESC, Colors~AU~, Fetish: Wanted, Incolore
itch: soraille
Location: Philippines
Contact:

Re: Instant CG and BG gallery

#58 Post by ppppantsu » Sun Feb 16, 2014 11:38 pm

Uhm hi! so I have a little problem--
I've read through the comments before finally decided to post a reply here.
first, here's the error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While executing init code:
  File "game/gallery.rpy", line 36, in script
  File "game/gallery.rpy", line 40, in python
Exception: Expected an image, but got a general displayable.

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

Full traceback:
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\bootstrap.py", line 265, in bootstrap
    renpy.main.main()
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\main.py", line 263, in main
    game.context().run(node)
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\ast.py", line 720, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\python.py", line 1304, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/gallery.rpy", line 40, in <module>
    renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\display\im.py", line 641, in __init__
    im = image(im)
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\display\im.py", line 1534, in image
    return image(arg.target, loose=loose, **properties)
  File "C:\Users\mmmkay\Desktop\renpy\renpy-6.16.3-sdk\renpy\display\im.py", line 1549, in image
    raise Exception("Expected an image, but got a general displayable.")
Exception: Expected an image, but got a general displayable.

Windows-Vista-6.0.6001-SP1
Ren'Py 6.16.3.502
Fetish 2.0
here's the line 40:

Code: Select all

    
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
but if I replace the original code with this (temporarily):

Code: Select all

    
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale("lockedcg.png", thumbnail_x, thumbnail_y))
IT WORKS! Although there's no thumbnail of my CGs, and shows the lockedcg.png image instead.

lockedcg.png by the way is my image during the time all CGs are still locked. In original code, it's the gallocked.png right?

but I always get an error when I use the original code. >A<

here's my full code:

Code: Select all

##############################################################################
# CG Gallery

screen cg_gallery:
    
    tag menu

init python:
    #Galleries settings - start
    #list the CG gallery images here:
    gallery_cg_items = ["bg doll close", "cg1"]
    
    #how many rows and columns in the gallery screens?
    gal_rows = 3
    gal_cols = 4
    
    #thumbnail size in pixels:
    thumbnail_x = 140
    thumbnail_y = 106
    
    #Galleries settings - end
    
    gal_cells = gal_rows * gal_cols    
    g_cg = Gallery()
    for gal_item in gallery_cg_items:
        g_cg.button(gal_item + " butt")
        g_cg.image(gal_item)
        g_cg.unlock(gal_item)
    
        if gal_item == "bg doll close":
            g_cg.image("bg doll open")
            g_cg.unlock("bg doll open")
    g_cg.transition = dissolve
    cg_page=0
    
init +1 python:
    #Here we create the thumbnails. We create a grayscale thumbnail image for BGs, but we use a special "locked" image for CGs to prevent spoilers.
    
    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
        
screen cg_gallery:
    tag menu
    use navigation
    frame background None xpos 10:
        grid gal_rows gal_cols:
            ypos 10
            $ i = 0
            $ next_cg_page = cg_page + 1            
            if next_cg_page > int(len(gallery_cg_items)/gal_cells):
                $ next_cg_page = 0
            for gal_item in gallery_cg_items:
                $ 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", im.Scale("lockedcg.png", thumbnail_x, thumbnail_y), 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
        frame:
            yalign 0.97
            vbox:
                if len(gallery_cg_items)>gal_cells:
                    textbutton _("Next Page") action [SetVariable('cg_page', next_cg_page), ShowMenu("cg_gallery")]

so yeah, my main problem is the common error I think everyone got at the

Code: Select all

    for gal_item in gallery_cg_items:
        renpy.image (gal_item + " butt", im.Scale(ImageReference(gal_item), thumbnail_x, thumbnail_y))
I've been browsing this thread over and over again but my problem isn't fixed.
though I somehow managed to partially make it work, no thumbnails are shown and the same old error pops out.

i feel stupid. OTL
thank you for your help in advance. >A<

User avatar
leon
Miko-Class Veteran
Posts: 554
Joined: Sun Oct 09, 2011 11:15 pm
Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
Organization: Team ANARKY
Contact:

Re: Instant CG and BG gallery

#59 Post by leon » Mon Feb 17, 2014 4:19 am

The problem seems to be in this line:

Code: Select all

    gallery_cg_items = ["bg doll close", "cg1"]
Double check that the images listed here are defined somewhere and spelled correctly.

Mitula
Newbie
Posts: 8
Joined: Sun Mar 10, 2013 1:19 pm
Contact:

Re: Instant CG and BG gallery

#60 Post by Mitula » Wed Feb 26, 2014 4:48 am

Hello,

Firstly, thank you for this code works perfectly. My only question is:

I have a CG that are smaller than the size of my window. How to put a background behind (instead of the default gray square) and how to center the CG ?

Post Reply

Who is online

Users browsing this forum: No registered users