Help in understanding how to make duplicate

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,082
4,430
Hello. I have a great gallery working on my game I am creating. However, I would like to create another gallery for a different purpose.
I would like to use the same gallery code I have for the use of displaying another type of gallery but I have a problum, every time I change the gallery code to fit the new gallery I get an error saying that it is not defined.

Here is my original gallery code.

Python:
###############GALLERY##################
init python:

   # Step 1. Create the gallery object.
    g = Gallery()

    g.locked_button = "gallery/locked.png"

   # Step 2. Add buttons and images to the gallery.

   # A button that contains an image that automatically unlocks.
    g.button("sex1")
    g.condition("persistent.unlock_1")
    g.image("nebulan01")


    g.button("sex2")
    g.condition("persistent.unlock_2")
    g.image("image1")


    g.button("sex3")
    g.condition("persistent.unlock_3")
    g.image("image1")


    g.button("sex4")
    g.condition("persistent.unlock_4")
    g.image("image1")


    g.button("sex5")
    g.condition("persistent.unlock_5")
    g.image("image1")



    g.button("sex6")
    g.condition("persistent.unlock_6")
    g.image("image1")

    g.button("sex7")
    g.condition("persistent.unlock_7")
    g.image("image1")


    g.button("sex8")
    g.condition("persistent.unlock_8")
    g.image("image1")

    g.button("sex9")
    g.condition("persistent.unlock_9")
    g.image("image1")

    g.button("sex10")
    g.condition("persistent.unlock_10")
    g.image("image1")

    g.button("sex11")
    g.condition("persistent.unlock_11")
    g.image("")

    g.button("sex12")
    g.condition("persistent.unlock_12")
    g.image("")

    g.button("sex13")
    g.condition("persistent.unlock_13")
    g.image("")

    g.button("sex14")
    g.condition("persistent.unlock_14")
    g.image("")

    g.button("sex15")
    g.condition("persistent.unlock_15")
    g.image("")

    g.button("sex16")
    g.condition("persistent.unlock_16")
    g.image("")

    g.button("sex17")
    g.condition("persistent.unlock_17")
    g.image("")

    g.button("sex18")
    g.condition("persistent.unlock_18")
    g.image("")

    g.button("sex19")
    g.condition("persistent.unlock_19")
    g.image("")

    g.button("sex20")
    g.condition("persistent.unlock_20")
    g.image("")

screen gallery:

   # Ensure this replaces the main menu.
    tag menu

   # The background.
    add "backgroundscifi"

   # A grid of buttons.
    grid 4 3:

        xfill True
        yfill True

        # Call make_button to show a particular button.
        add g.make_button("sex1", "gallery/unlock1.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex2", "gallery/unlock2.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex3", "gallery/unlock3.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex4", "gallery/unlock4.png", xalign=0.5, yalign=0.5)

        add g.make_button("sex5", "gallery/unlock5.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex6", "gallery/unlock6.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex7", "gallery/unlock7.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex8", "gallery/unlock8.png", xalign=0.5, yalign=0.5)

        add g.make_button("sex9", "gallery/unlock9.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex10", "gallery/unlock10.png", xalign=0.5, yalign=0.5)

        imagebutton:
            idle "gallery/page2.png"
            action ShowMenu("gallery2")
            xalign 0.5
            yalign 0.5

        imagebutton:
            idle "gallery/main menu.png"
            action Return()
            xalign 0.5
            yalign 0.5

screen gallery2:

   # Ensure this replaces the main menu.
    tag menu

   # The background.
    add "backgroundscifi"

   # A grid of buttons.
    grid 4 3:

        xfill True
        yfill True

        # Call make_button to show a particular button.
        add g.make_button("sex11", "gallery/unlock11.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex12", "gallery/unlock12.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex13", "gallery/unlock13.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex14", "gallery/unlock14.png", xalign=0.5, yalign=0.5)

        add g.make_button("sex15", "gallery/unlock15.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex16", "gallery/unlock16.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex17", "gallery/unlock17.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex18", "gallery/unlock18.png", xalign=0.5, yalign=0.5)

        add g.make_button("sex19", "gallery/unlock19.png", xalign=0.5, yalign=0.5)
        add g.make_button("sex20", "gallery/unlock20.png", xalign=0.5, yalign=0.5)

        imagebutton:
            idle "gallery/page1.png"
            action ShowMenu("gallery")
            xalign 0.5
            yalign 0.5

        imagebutton:
            idle "gallery/main menu.png"
            action Return()
            xalign 0.5
            yalign 0.5
What I want to do is make a copy of this gallery and have another link in the main menu to access it.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,082
4,430
The first thing I did was make a copy of the gallery script and name it biolist.rpy then I changed

# Step 1. Create the gallery object.
g = Gallery()

to

# Step 1. Create the gallery object.
r = race()

then replaced all the g. to r. in the code

r.button("sex1")
r.condition("persistent.unlock_1")
r.image("nebulan01")


r.button("sex2")
r.condition("persistent.unlock_2")
r.image("image1")
ect...

What else do I need to do or have I done it all wrong. any help is much apriciated. thank you so much.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
# Step 1. Create the gallery object.
r = race()
What do this mean ? Or, if you prefer, why this and not what you should have wrote : r = Gallery()

You should take some times to find a basic introduction to Python language, and read it. It would help you having a better understanding of what you copy from documentation/piece of code found here and there, how it works, and so in the end how to use it yourself.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,082
4,430
well I changed r = Gallery() to r = race() because I already had a gallery and thought that having 2 gallery would mess things up. but you are right I need to read more about python and understand things better. thanks
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,082
4,430
Ok my problum is that I have two gallery options listed here.

textbutton _("Alien Races") action ShowMenu("gallery")

textbutton _("Gallery") action ShowMenu("gallery")

then it only lists the same gallery for both. how do I change the alien race gallery to be a different gallery?

everytime I try to change it, it gives me an error.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
then it only lists the same gallery for both. how do I change the alien race gallery to be a different gallery?

I'll look rude, sorry by advance, readers could tell you that I'm generally a nice guy, but it need to be said, and coating it in sugar would be counter productive for you.

You clearly know less than nothing about coding, what by itself is fine, half of the devs on the indie adult scene was in the same shoes than you before starting to make their game. But there's a difference between them and you, they had conscience that they were facing a challenge and past few time reading Ren'py documentation, at least the " " section, and trying to at least understand the basis.

The problem you were facing at first, is understandable, it imply objects and their understanding. But this new problem is really purely basic and rely more on personal understanding. But not the understanding of something complex, it's not more complicated to understand, at least the big lines of this problem, than understanding a sentence in your native language.

You've this code textbutton _("Gallery") action ShowMenu("gallery"), that in words read as "display a button that will contain the text 'Gallery' [this part you figured it right], and that, when clicked, will show a menu described in a screen named 'gallery'".
And to add your second gallery, you added this code textbutton _("Alien Races") action ShowMenu("gallery"), that in words read as "display a button that will contain the text 'Alien Races', and that, when clicked, will show a menu described in a screen named 'gallery'".

Don't you see the problem ? Both point to the same screen (a really basis notion of Ren'py) that is the exact same one. So obviously, both window will show the same content, since they show the same screen.

And, no, just changing ShowMenu("gallery") into ShowMenu("alien race") would not works.
Firstly because there's a space in the screen name, what isn't permit. Secondly because this screen do not exist yet. You've to create it, and you've to adapt it for it to use your second gallery (r), before anything else can works.

This is really the basis of logic, to have something different on the screen, you need to display something different, as well as the basis of Ren'py, to display a screen, this screen need to exist.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,082
4,430
I understand everything you have said about textbutton _("Alien Races") action ShowMenu("gallery") that it needs to point to a screen named alienraces. what I dont understand is where I am to create the screen, and how. that is all I am asking.

My apologize if I explained things incorrect, most of the time I figure things out on my own for renpy and I am a very determined individual, but sometimes I just need to get some advice from others on what to do, even if what I am trying to do is very simple.

Also Yes I know I am crap at coding, my whole life I have been a 3D artist, so coding is not my strong suit, but that does not mean I will give up.

anyways thanks you for your help.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
I figured it all out. Thanks :)
Happy for you, really.

I wasn't ghosting you, but you already had, with my last answer, everything you needed to find the solution by yourself. As I said, it's something basic, giving you the whole answer would have been counter-productive for you ; teaching you to rely on others while you could, and did, solve this by yourself.
 
  • Like
Reactions: Incyder