How to use the CG Gallery code?

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.
Message
Author
User avatar
Lumen_Astrum
Dystopian Princess
Posts: 1662
Joined: Mon Nov 08, 2010 8:01 am
Completed: Soul and Heart, Twin Faces
Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
Organization: Lion Box Studios
Tumblr: lumenizampel
Location: Philippines
Contact:

How to use the CG Gallery code?

#1 Post by Lumen_Astrum » Thu Sep 08, 2011 9:32 am

I'm sorry, but I really can't understand what's written in the cookbook =_=

Can anyone explain to me how does it work? Thanks and sorry :|

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: How to use the CG Gallery code?

#2 Post by DaFool » Thu Sep 08, 2011 10:37 pm

This one?

http://www.renpy.org/wiki/renpy/doc/coo ... CG_Gallery

Just drop the script in and replace the images with your own.

Unless there's an even newer method floating about that's done with screens? (I haven't personally used CG gallery in 2 years)

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#3 Post by Soraminako » Fri Sep 09, 2011 12:04 am

Lumen_Astrum isn't alone in having problems with the gallery.

The page for the gallery code is pretty much only comprehensible for someone having mastered advanced rocket science in the ren'py subject. ^^;

Anyone else, and especially anyone like me with beginner level ren'py understanding stands no chance of setting up a functioning gallery.
At least that's the impression I've gotten from the cookbook and from my countless attempts of making the code work. The rest of my game works just fine right now, but the gallery is an endless succession of failed attempts, much to my frustration. ^^;

It's horribly frustrating, because a gallery seems like something that would be so great to have in one's game, if it was possible to use the code. But it just sits there, sadistically tempting us newbies with how nice it must be if we could use it... :P

At least you replied to a gallery thread. ^^; I've asked for help with the gallery various times before and never heard back from anyone. ^^; I suspect it's because implementing it in a way that works must be so hard that few people are using it, maybe? As a result few people are available to help with it, maybe.

I don't know if we just aren't setting it up right or if there's something else to do to make it work or what, but the way it is the code doesn't work. At least not when I put it in my script.rpy

Maybe it's just because it lacking explanations about what each part is makes that we use the wrong things and so it ends up not working?
Some of the cookbook pages are explained in detail and very helpful, but some others seem to be targeted at advanced level users and are totally confusing for anyone not used to what's being mentioned. :(


Using that code + another bit I got from a past thread I am able to have a page show up saying that the gallery hasn't been unlocked yet, but that's all. I can't make it work the way I imagine it should. It's frustrating. ^^;
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: How to use the CG Gallery code?

#4 Post by DaFool » Fri Sep 09, 2011 1:21 am

Soraminako wrote: Using that code + another bit I got from a past thread I am able to have a page show up saying that the gallery hasn't been unlocked yet, but that's all. I can't make it work the way I imagine it should. It's frustrating. ^^;
Just insert a persistent variable somewhere in your script to show that the game is completed, e.g.

Code: Select all

    $ persistent.beat_game = True
Then in the gallery code, instead of "True" use persistent.beat_game == True (or even just persistent.beat_game since True is assumed) for the condition statement that tells whether the gallery or image should unlock.

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#5 Post by Soraminako » Fri Sep 09, 2011 2:34 am

Yeah, I have the persistent in there and everything. It still doesn't work. :(
I'm clearly doing something wrong somewhere, but I have no idea how to have it all work properly.

I really can't figure out what could possibly be wrong with it. I've tried so many different times and nothing I do fixes it. All I've ever managed to do with the gallery is to make it show the "gallery not unlocked yet" thing and that's it.

So tonight the frustration over this hit a point so high that I just deleted what I had there and wrote a completely new gallery code from scratch. (Booze is probably the only thing that gave me the confidence to try such a thing despite my code noobness. lol)

Knowing that I'm a huge code noob, my new gallery is incredibly primitive and requires a few lines of code for each image it displays, but it does actually load and displays images!! And It looks exactly how I wanted it to since I built it like a custom menu and so I can have image buttons and everything placed where I wanted it to go.
So I'm partially happy right now. Some success, finally. XD I'm starting to get the grip of how to use ren'py and it's an immense satisfaction to see something I made from scratch actually working. :D

The one thing that really bothers me though is that my custom gallery can display the images but doesn't know how to differentiate between the locked and the unlocked ones. So anyone having played through the game and unlocked one ending will see also the endings they haven't unlocked yet. I have no idea how to avoid that. :(
(Other than having a sub-gallery for each ending.)

In the end, my custom gallery is something I'm happy to have been able to make as a learning thing, but it's nowhere near how awesome the official one from the cookbook with its locked/unlocked abilities must be, for people who can make it work. :(


If by any chance you feel like explaining the cookbook one so that we (and no doubt countless other people also) could use a real gallery with unlocked/locked images, it would be truly awesome!!


Edit to add:

After much tweaking I found a stupid mistake I'd made somewhere, and now the cookbook gallery will load. I still can't make it work like a gallery, but it's showing up at least...
It only displays the locked image thumbnail, but refuses to show any unlocked images though, so presumably I have other problems elsewhere, but I can't seem to figure out what. :(

Hopefully I can figure out what I'm doing wrong where, so I can finally use the cookbook gallery instead of having to use my own primitive gallery. :?
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Abeiramar
Regular
Posts: 198
Joined: Wed Jul 28, 2010 10:37 am
Location: Portugal
Contact:

Re: How to use the CG Gallery code?

#6 Post by Abeiramar » Fri Sep 09, 2011 9:10 am

I used the gallery from the cookbook and it works for me. Here's how I did it...

* Got to: http://www.renpy.org/wiki/renpy/doc/coo ... CG_Gallery

* Click on the new_gallery.rpy link. Copy it.
*Now open Renpy and click "Edit Script".
*Go to File>New and paste the code you copied. Save it as new_gallery.rpy or something.rpy . PLEASE NEVER FORGET .RPY , IT'S VERY IMPORTANT or the game will not read the file.

Here's how it looks like:
Image

*Now create a new .rpy file (File>New).
Post the code you see below.
The one in the Ren'py webpage had a minor glitch, I fixed it...**

Code: Select all

init:
    # Position the navigation on the right side of the screen.
    $ style.gallery_nav_frame.xpos = 800 - 10
    $ style.gallery_nav_frame.xanchor = 1.0
    $ style.gallery_nav_frame.ypos = 12

    # Add the gallery to the main menu.
    $ config.main_menu.insert(2, ('Gallery', "gallery", "True"))

# The entry point to the gallery code.
label gallery:
    python hide:

        # Construct a new gallery object.
        g = Gallery()

        # The image used for locked buttons.
        g.locked_button = "gallery_locked.png"

        # The background of a locked image.
        g.locked_background = "gallery_lockedbg.jpg"

        # Frames added over unlocked buttons, in hover and idle states.
        g.hover_border = "gallery_hover.png"
        g.idle_border = "gallery_idle.png"

        # An images used as the background of the various gallery pages.
        g.background = "gallery_background.jpg"

        # Lay out the gallery images on the screen.
        # These settings lay images out 3 across and 4 down.
        # The upper left corner of the gird is at xpos 10, ypos 20.
        # They expect button images to be 155x112 in size.
        g.grid_layout((3, 4), (10, 12), (160, 124))

        # Show the background page.
        g.page("Backgrounds")

        # Our first button is a picture of the beach.
        g.button("thumb_beach.jpg")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("bg beach daytime")
        g.unlock_image("bg beach nighttime")
        #
        # This shows a displayable...
        g.display("beach_sketch.jpg")
        # ... if all prior images have been show.
        g.allprior()

        # A second set of images.
        g.button("thumb_lighthouse.jpg")
        g.unlock_image("bg lighthouse day")
        g.unlock_image("bg lighthouse night")
        g.display("lighthouse_sketch.jpg")
        g.allprior()



        # We can use g.page to introduce a second page.
        g.page("Characters")

        g.button("thumb_eileen.jpg")
        #
        # Note that we can give image and unlock image more than one image
        # at a time.
        g.unlock_image("bg lighthouse day", "eileen day happy")
        g.unlock_image("bg lighthouse day", "eileen day mad")



        # Another page, this one for concept art.
        g.page("Concept Art")

        g.button("thumb_concepts.jpg")
        #
        # We can apply conditions to buttons as well as to images.
        # The "condition" condition checks an arbitrary expression.
        g.condition("persistent.beat_game")
        #
        g.display("concept1.jpg")
        g.display("concept2.jpg")
        g.display("concept3.jpg")


        # Now, show the gallery.
        g.show()

    jump main_menu_screen
File>Save as... and name it whateveryouwant.rpy . I named it art.rpy :
Image
Read the informations on the code carefully and replace all images with images existent in your game directory!
Remember to create a lock button, frames and thumbnails with 155x112 size in your image editor and put it in your game directory.

*Now you need to add an option on you main_menu and all that jazz!
Click on screens.rpy and look for this section of code:
(It's under the main menu section!)

Code: Select all


        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit(confirm=False)

Add this:

Code: Select all

        textbutton _("CG Gallery") action ShowMenu("gallery")
Now a CG Gallery button will appear in the main menu of your game :D !
Did you replace all the images? It should look like this now... or full of locks :wink:, either way it's fine:

Image

Yeah, nevermind the images I did this in a rush... But you can make it look pretty! Anyway, now let's change the background.

*Go to new_galley.rpy !
Look for this section of code:

Code: Select all

        def __init__(self):
            self.pages = [ ]

            self.page_ = None
            self.button_ = None
            self.image_ = None
            self.unlockable = None
            
        def page(self, name, background=None):

See " background=None " ? Replace it with

Code: Select all

        background ="mybackground.jpg"
"mybackground.jpg" is a image of your choice :) .
It looks like this now:

Image

I hope this was useful in some way, if you have any questions please ask me...I'm a newbie and my python skills are poor. However, I will try to help you guys the best I can!

**For some reason the word "return" makes the game start. I replaced with "jump main_menu_screen" so the user can go back to the main menu

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#7 Post by Soraminako » Fri Sep 09, 2011 3:55 pm

Abeiramar wrote:I used the gallery from the cookbook and it works for me. Here's how I did it...
[...]
I hope this was useful in some way, if you have any questions please ask me...I'm a newbie and my python skills are poor. However, I will try to help you guys the best I can!

**For some reason the word "return" makes the game start. I replaced with "jump main_menu_screen" so the user can go back to the main menu
OMG YOU ARE AWESOME!! *____* Thank you so much!

I replaced the code I kept struggling with with the one you gave and now it all works!!

I have no idea what was wrong before, but now it works beautifully!! (Well, messily since it's still test images and the overall look isn't all pretty and customized yet but it actually loads the images and does everything it's supposed to do. *dances with joy*

Thank you so much! Your explanation is what made it possible! :D I'm sure many other beginners like me will be so grateful for it as well!

I'll go play with it now and come back when I break it ^^; if/when I run into something I don't understand and need to ask for additional details on anything. :D

*so happy* :D :D



Edit to add a little question: I see you can jump to the main menu using "jump main_menu_screen", and was wondering what would be the names to jump to the load and preferences menus. And whether it would be best to customize their looks through the screens.rpy or by using custom menus?

I have a weird little problem now, because I wasn't using the screens.rpy before (even though I'm using the latest ren'py, but I just don't understand screens), and now that I've added it to my folder, when I click the button to return to the main menu (from the preferences menu, or load menu), it sends me to a basic main menu rather than to my custom one.
Is there something I should replace in the screen files so that it all goes back to my custom main menu? (Which is in a label in the script.rpy)
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Abeiramar
Regular
Posts: 198
Joined: Wed Jul 28, 2010 10:37 am
Location: Portugal
Contact:

Re: How to use the CG Gallery code?

#8 Post by Abeiramar » Fri Sep 09, 2011 9:03 pm

Edit to add a little question: I see you can jump to the main menu using "jump main_menu_screen", and was wondering what would be the names to jump to the load and preferences menus. And whether it would be best to customize their looks through the screens.rpy or by using custom menus?

I have a weird little problem now, because I wasn't using the screens.rpy before (even though I'm using the latest ren'py, but I just don't understand screens), and now that I've added it to my folder, when I click the button to return to the main menu (from the preferences menu, or load menu), it sends me to a basic main menu rather than to my custom one.
Is there something I should replace in the screen files so that it all goes back to my custom main menu? (Which is in a label in the script.rpy)
To go to the preferences screen...

Code: Select all

    
    jump preferences_screen
instead of "jump main_menu_screen"
or

Code: Select all

    
    jump load_screen
To go to the load screen!

I find this tutorial to customize the main menu very helpful: http://lemmasoft.renai.us/forums/viewto ... f=8&t=9812

Anyway, are you using hotspots for customizing your main menu? Maybe you should send me the code :wink: .

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#9 Post by Soraminako » Fri Sep 09, 2011 10:16 pm

Abeiramar wrote:[...]

Anyway, are you using hotspots for customizing your main menu? Maybe you should send me the code :wink: .
Thank you for the explanation & link! :D

As for my menu, I'm using the code given by Aleema in this thread: http://lemmasoft.renai.us/forums/viewto ... f=8&t=6998
It makes it so easy to create something nice with image buttons!
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Lumen_Astrum
Dystopian Princess
Posts: 1662
Joined: Mon Nov 08, 2010 8:01 am
Completed: Soul and Heart, Twin Faces
Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
Organization: Lion Box Studios
Tumblr: lumenizampel
Location: Philippines
Contact:

Re: How to use the CG Gallery code?

#10 Post by Lumen_Astrum » Sat Sep 10, 2011 12:54 am

THANK YOU! *_*

One question though -- I don't really want to call the CG gallery from the main menu, tehehe.
In my main menu, there's a button there that calls a menu (for the bonuses), and I was planning that menu to call the CG gallery from one of the choices.

How to do that? O:

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#11 Post by Soraminako » Sat Sep 10, 2011 2:43 am

Lumen_Astrum wrote:One question though -- I don't really want to call the CG gallery from the main menu, tehehe.
In my main menu, there's a button there that calls a menu (for the bonuses), and I was planning that menu to call the CG gallery from one of the choices.

How to do that? O:
Are you using a custom menu? You could always have a button in the main menu to send the players to the bonus area (instead of a gallery button), and then have the button to the gallery being in that bonus area instead of being in the main menu itself.
The gallery itself is in its own label, so it should be possible. (I have no idea how to make it work with screens, but with the custom menu it should work.)

In my code I have a custom menu like this:

Code: Select all

label main_menu:
    scene mainmenu
        
    $ ui.hbox(xpos=70, ypos=350)
    $ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
    $ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
    $ ui.imagebutton("cg1.png", "cg2.png", clicked=ui.returns("gallery"))
    $ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
    $ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
    $ ui.close()

    $ result = ui.interact()
   
    if result == "start":
        hide mainmenu
        $ renpy.jump_out_of_context("start")
    elif result == "load":
        jump load_screen
    elif result == "gallery":
        jump gallery
    elif result == "prefs":
        jump preferences_screen
    elif result == "quit":
        $ renpy.quit()

You could probably use the same type of thing, but instead of putting "gallery", you put "bonus" and make a bonus label, in which you put a button to the gallery as well as the rest of your stuff.

The gallery seems to support a variety of different sub-areas, so I'll probably just set up my bonuses there. :)

I'm not sure if I could have a music gallery in it though. That would be an interesting bonus as well.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Lumen_Astrum
Dystopian Princess
Posts: 1662
Joined: Mon Nov 08, 2010 8:01 am
Completed: Soul and Heart, Twin Faces
Projects: Soul and Heart Replay; The Court of the Two Sides (tentative title)
Organization: Lion Box Studios
Tumblr: lumenizampel
Location: Philippines
Contact:

Re: How to use the CG Gallery code?

#12 Post by Lumen_Astrum » Sat Sep 10, 2011 4:30 am

Yes, yes, that's what I'm talking about. :D
The CG gallery should be in the bonus area, but I dunno how to call it. :|

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#13 Post by Soraminako » Sat Sep 10, 2011 5:01 am

Lumen_Astrum wrote:Yes, yes, that's what I'm talking about. :D
The CG gallery should be in the bonus area, but I dunno how to call it. :|
I built a bonus area like that tonight, from which the player can go to either the gallery or to the music room. (Or return to the main menu.)

Do you want to use custom ui menus, or are you using screens?

I have no idea how to use screens, so I'm using just the ui image buttons. But it has problems if you plan to use screens in your game. At least, I was having problems when using them together. (Probably just because I don't know what to edit in the screens to make them work together.)
So I had to delete the screens from my game for now.

If you don't plan to use the screens.rpy, I could go fetch the code I'm using and paste it here, since it works the way the room you want does. But if you prefer to use screens, it might not work well together. ^^;


Edit:
I fetched the code. Here it is in case you decide to use ui buttons. The only problem between this and screens is that unless you know how to edit the screen.rpy file to avoid that problem, once you click to return to the main menu you'll be shown the basic theme's menu instead of your custom one.
(If you do know how to edit screens to avoid that, please let me know. I'm still pulling my hair over how confused I am by screens. :? )

Please ignore how random my images and musics are right now. XD I was just testing stuff.

Code: Select all

## Somewhere around the beginning of script.rpy

####################
# MUSIC ROOM part 1 of 2


init python:

    def set_playing_(track):
        store.playing = track
        return True

    set_playing = renpy.curry(set_playing_)

    # Call this with a button name and a track to define a music
    # button.
    def music_button(name, track):

        if store.playing == track:
            role = "selected_"
        else:
            role = ""

        if not renpy.seen_audio(track):
            name = "???"
            clicked = None
        else:
            clicked = set_playing(track)
        
            
        ui.textbutton(
            name,
            clicked=clicked,
            role=role,
            size_group="music")
    
    # Add to the main menu.
    config.main_menu.insert(3, ("Music Room", "music_room", "True"))



############################
# GALLERY


init:
    # Position the navigation on the right side of the screen.
    $ style.gallery_nav_frame.xpos = 800 - 10
    $ style.gallery_nav_frame.xanchor = 1.0
    $ style.gallery_nav_frame.ypos = 12

    # Add the gallery to the main menu.
    $ config.main_menu.insert(2, ('Gallery', "gallery", "True"))

# The entry point to the gallery code.
label gallery:
    

    if not persistent.gallery_unlocked:
        show lockedG_background
        centered "You haven't unlocked this gallery yet."
        $ renpy.full_restart()
    
        
    
    
    python hide:

        # Construct a new gallery object.
        g = Gallery()

        # The image used for locked buttons.
        g.locked_button = "gallery_locked.png"

        # The background of a locked image.
        g.locked_background = "gallery_lockedbg.jpg"

        # Frames added over unlocked buttons, in hover and idle states.
        g.hover_border = "gallery_hover.png"
        g.idle_border = "gallery_idle.png"

        # An images used as the background of the various gallery pages.
        g.background = "gallery_background.jpg"

        # Lay out the gallery images on the screen.
        # These settings lay images out 3 across and 4 down.
        # The upper left corner of the gird is at xpos 10, ypos 20.
        # They expect button images to be 155x112 in size.
        g.grid_layout((3, 4), (10, 12), (160, 124))

        # Show the background page.
        g.page("Backgrounds")

        # Our first button is a picture of the beach.
        g.button("thumb_beach.jpg")
        #
        # These show images, if they have been unlocked. The image name must
        # have been defined using an image statement.
        g.unlock_image("bg beach daytime")
        g.unlock_image("bg beach nighttime")
        #
        # This shows a displayable...
        g.display("beach_sketch.jpg")
        # ... if all prior images have been show.
        g.allprior()

        # A second set of images.
        g.button("thumb_beach.jpg")
        g.display("beach_sketch.jpg")
        g.unlock_image("bg beach nighttime")
        g.unlock_image("bg beach daytime")
        g.allprior()



        # We can use g.page to introduce a second page.
        g.page("Characters")

        g.button("thumb_guy.jpg")
        #
        # Note that we can give image and unlock image more than one image
        # at a time.
        g.unlock_image("bg beach daytime", "guy01")
        g.unlock_image("bg beach nighttime", "guy02")



        # Another page, this one for concept art.
        g.page("Concept Art")

        g.button("thumb_beach.jpg")
        #
        # We can apply conditions to buttons as well as to images.
        # The "condition" condition checks an arbitrary expression.
        g.condition("persistent.gallery_unlocked")
        #
        g.display("bg01.jpg")
        g.display("bg02.jpg")



        # Now, show the gallery.
        g.show()

    jump main_menu



########################
# MUSIC ROOM part 2 of 2


label music_room:

    scene black

    python:
        _game_menu_screen = None

        # The default track of music.
        playing = "music1.wav"
        
label music_room_loop:

    # Play the playing music, if it changed.
    python:
        renpy.music.play(playing, if_changed=True, fadeout=1)

        # Display the various music buttons.
        ui.vbox(xalign=0.5, ypos=100)
        music_button("music 1", "music1.wav")
        music_button("music 2", "music2.mp3")
        music_button("music 3", "music3.mp3")
        ui.close()

        # This is how we return to the main menu.
        ui.textbutton(
            "Return",
            clicked=ui.returns(False),
            xalign=0.5,
            ypos=450,
            size_group="music")


    if ui.interact():
        jump music_room_loop
    else:
        $ _game_menu_screen = "save_screen"
        jump main_menu



################################
# LABEL BONUS ROOM
################################

label bonus:
    scene black

        
    $ ui.hbox(xpos=150, ypos=350)
    $ ui.imagebutton("gallery1.png", "gallery2.png", clicked=ui.returns("gallery"))
    $ ui.imagebutton("musicroom1.png", "musicroom2.png", clicked=ui.returns("music"))
    $ ui.imagebutton("back1.png", "back2.png", clicked=ui.returns("back"))
    $ ui.close()

    $ result = ui.interact()
   
    if result == "gallery":
        jump gallery
    elif result == "music":
        jump music_room
    elif result == "back":
        jump main_menu





##############


label main_menu:
    scene mainmenu
        
    $ ui.hbox(xpos=69, ypos=350)
    $ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
    $ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
    $ ui.imagebutton("bonusbutton1.png", "bonusbutton2.png", clicked=ui.returns("bonus"))
    $ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
    $ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
    $ ui.close()

    $ result = ui.interact()
   
    if result == "start":
        hide mainmenu
        $ renpy.jump_out_of_context("start")
    elif result == "load":
        jump load_screen
    elif result == "bonus":
        jump bonus
    elif result == "prefs":
        jump preferences_screen
    elif result == "quit":
        $ renpy.quit()



There's not really a reason why I separated the music room code chunks. You can probably leave them together.
I have a lot of other stuff in between them normally and so I pasted the second chunk farther down because I wanted it closer to the main menu so I could scroll less to edit the musics while typing my code. XD
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How to use the CG Gallery code?

#14 Post by Aleema » Sat Sep 10, 2011 11:59 am

Heh. That main menu code is old. Screen language (screens.rpy) has a main menu screen just like that but with SL.

To keep the SL screens and your screens from clashing, delete the SL screens you don't want. Meaning, delete "screen main_menu" completely and the bugs should stop happening. You can always get the code again later, it's always in your "template" game and in the documentation.

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: How to use the CG Gallery code?

#15 Post by Soraminako » Sat Sep 10, 2011 12:26 pm

Aleema wrote:Heh. That main menu code is old. Screen language (screens.rpy) has a main menu screen just like that but with SL.

To keep the SL screens and your screens from clashing, delete the SL screens you don't want. Meaning, delete "screen main_menu" completely and the bugs should stop happening. You can always get the code again later, it's always in your "template" game and in the documentation.
Aleema-sama! :D (I've been learning so much from your various posts, they're so useful!)

I'd love to use screens, if I could understand it. It's just so complicated. :(
I use the old menu because it's so simple and effective. Really easy to set up and looks just like I wanted it to. So it's very tempting regardless of being old... :)

Is there a tutorial somewhere explaining how to use screens and how to customize the stuff in it? What you mentioned seems like it would be such a great option.

What's SL? ^^; I only had the one screens.rpy.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

Post Reply

Who is online

Users browsing this forum: rayminator