How to make 2 copies of a gallery
Posted: Tue Feb 16, 2021 12:20 pm
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 problem, 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.
###############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("set1")
g.condition("persistent.unlock_1")
g.image("image1")
g.button("set2")
g.condition("persistent.unlock_2")
g.image("image1")
g.button("set3")
g.condition("persistent.unlock_3")
g.image("image1")
g.button("set4")
g.condition("persistent.unlock_4")
g.image("image1")
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("set1", "gallery/unlock1.png", xalign=0.5, yalign=0.5)
add g.make_button("set2", "gallery/unlock2.png", xalign=0.5, yalign=0.5)
add g.make_button("set3", "gallery/unlock3.png", xalign=0.5, yalign=0.5)
add g.make_button("set4", "gallery/unlock4.png", xalign=0.5, yalign=0.5)
add g.make_button("set5", "gallery/unlock5.png", xalign=0.5, yalign=0.5)
add g.make_button("set6", "gallery/unlock6.png", xalign=0.5, yalign=0.5)
add g.make_button("set7", "gallery/unlock7.png", xalign=0.5, yalign=0.5)
add g.make_button("set8", "gallery/unlock8.png", xalign=0.5, yalign=0.5)
add g.make_button("set9", "gallery/unlock9.png", xalign=0.5, yalign=0.5)
add g.make_button("set10", "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("set11", "gallery/unlock11.png", xalign=0.5, yalign=0.5)
add g.make_button("set12", "gallery/unlock12.png", xalign=0.5, yalign=0.5)
add g.make_button("set13", "gallery/unlock13.png", xalign=0.5, yalign=0.5)
add g.make_button("set14", "gallery/unlock14.png", xalign=0.5, yalign=0.5)
add g.make_button("set15", "gallery/unlock15.png", xalign=0.5, yalign=0.5)
add g.make_button("set16", "gallery/unlock16.png", xalign=0.5, yalign=0.5)
add g.make_button("set17", "gallery/unlock17.png", xalign=0.5, yalign=0.5)
add g.make_button("set18", "gallery/unlock18.png", xalign=0.5, yalign=0.5)
add g.make_button("set19", "gallery/unlock19.png", xalign=0.5, yalign=0.5)
add g.make_button("set20", "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
############################################################## END
I need help in understanding how to use this as a gallery for my main game alongside the current gallery that is there.
in my main menu I have this gallery accessed by
textbutton _("History") action ShowMenu("history")
textbutton _("Save") action ShowMenu("save")
textbutton _("Load") action ShowMenu("load")
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Gallery") action ShowMenu("gallery")
Please correct me if I am wrong. but I was under the impression I need to make a copy of this current gallery and change it to something else like Race.rpy
then change the
# Step 1. Create the gallery object.
g = Gallery()
to
# Step 1. Create the gallery object.
r = Race()
and then create a new menu action in the screens list like this
textbutton _("Race") action ShowMenu("race")
and I did that but I get an error that says race is undefined.
Anyways any help is greatly apriciated. I know almost nothing about coding so I am pretty green in this.
thank you very much
I would like to use the same gallery code I have for the use of displaying another type of gallery but I have a problem, 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.
###############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("set1")
g.condition("persistent.unlock_1")
g.image("image1")
g.button("set2")
g.condition("persistent.unlock_2")
g.image("image1")
g.button("set3")
g.condition("persistent.unlock_3")
g.image("image1")
g.button("set4")
g.condition("persistent.unlock_4")
g.image("image1")
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("set1", "gallery/unlock1.png", xalign=0.5, yalign=0.5)
add g.make_button("set2", "gallery/unlock2.png", xalign=0.5, yalign=0.5)
add g.make_button("set3", "gallery/unlock3.png", xalign=0.5, yalign=0.5)
add g.make_button("set4", "gallery/unlock4.png", xalign=0.5, yalign=0.5)
add g.make_button("set5", "gallery/unlock5.png", xalign=0.5, yalign=0.5)
add g.make_button("set6", "gallery/unlock6.png", xalign=0.5, yalign=0.5)
add g.make_button("set7", "gallery/unlock7.png", xalign=0.5, yalign=0.5)
add g.make_button("set8", "gallery/unlock8.png", xalign=0.5, yalign=0.5)
add g.make_button("set9", "gallery/unlock9.png", xalign=0.5, yalign=0.5)
add g.make_button("set10", "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("set11", "gallery/unlock11.png", xalign=0.5, yalign=0.5)
add g.make_button("set12", "gallery/unlock12.png", xalign=0.5, yalign=0.5)
add g.make_button("set13", "gallery/unlock13.png", xalign=0.5, yalign=0.5)
add g.make_button("set14", "gallery/unlock14.png", xalign=0.5, yalign=0.5)
add g.make_button("set15", "gallery/unlock15.png", xalign=0.5, yalign=0.5)
add g.make_button("set16", "gallery/unlock16.png", xalign=0.5, yalign=0.5)
add g.make_button("set17", "gallery/unlock17.png", xalign=0.5, yalign=0.5)
add g.make_button("set18", "gallery/unlock18.png", xalign=0.5, yalign=0.5)
add g.make_button("set19", "gallery/unlock19.png", xalign=0.5, yalign=0.5)
add g.make_button("set20", "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
############################################################## END
I need help in understanding how to use this as a gallery for my main game alongside the current gallery that is there.
in my main menu I have this gallery accessed by
textbutton _("History") action ShowMenu("history")
textbutton _("Save") action ShowMenu("save")
textbutton _("Load") action ShowMenu("load")
textbutton _("Preferences") action ShowMenu("preferences")
textbutton _("Gallery") action ShowMenu("gallery")
Please correct me if I am wrong. but I was under the impression I need to make a copy of this current gallery and change it to something else like Race.rpy
then change the
# Step 1. Create the gallery object.
g = Gallery()
to
# Step 1. Create the gallery object.
r = Race()
and then create a new menu action in the screens list like this
textbutton _("Race") action ShowMenu("race")
and I did that but I get an error that says race is undefined.
Anyways any help is greatly apriciated. I know almost nothing about coding so I am pretty green in this.
thank you very much