-- Instead of using the old (and seriously out-dated) 2-page gallery from the cookbook, I am attempting to upgrade to the the gallery Screen.
Code: Select all
init python:
# Step 1. Create the gallery object.
g = Gallery()
# Step 2. Add buttons and images to the gallery.
# A button that contains an image that automatically unlocks.
g.button("dawn")
g.image("dawn1")
g.unlock("dawn1")
# This button has multiple images associated with it. We use unlock_image
# so we don't have to call both .image and .unlock. We also apply a
# transform to the first image.
g.button("dark")
g.unlock_image("bigbeach1")
g.transform(slowpan)
g.unlock_image("beach1 mary")
g.unlock_image("beach2")
g.unlock_image("beach3")
# This button has a condition associated with it, allowing code
# to choose which images unlock.
g.button("end1")
g.condition("persistent.unlock_1")
g.image("transfer")
g.image("moonpic")
g.image("girlpic")
g.image("nogirlpic")
g.image("bad_ending")
g.button("end2")
g.condition("persistent.unlock_2")
g.image("library")
g.image("beach1 nomoon")
g.image("bad_ending")
# The last image in this button has an condition associated with it,
# so it will only unlock if the user gets both endings.
g.button("end3")
g.condition("persistent.unlock_3")
g.image("littlemary2")
g.image("littlemary")
g.image("good_ending")
g.condition("persistent.unlock_3 and persistent.unlock_4")
g.button("end4")
g.condition("persistent.unlock_4")
g.image("hospital1")
g.image("hospital2")
g.image("hospital3")
g.image("heaven")
g.image("white")
g.image("good_ending")
g.condition("persistent.unlock_3 and persistent.unlock_4")
# The final two buttons contain images that show multiple pictures
# at the same time. This can be used to compose character art onto
# a background.
g.button("dawn mary")
g.unlock_image("dawn1", "mary dawn wistful")
g.unlock_image("dawn1", "mary dawn smiling")
g.unlock_image("dawn1", "mary dawn vhappy")
g.button("dark mary")
g.unlock_image("beach2", "mary dark wistful")
g.unlock_image("beach2", "mary dark smiling")
g.unlock_image("beach2", "mary dark vhappy")
# The transition used when switching images.
g.transition = dissolve
# Step 3. The gallery screen we use.
screen gallery:
# Ensure this replaces the main menu.
tag menu
# The background.
add "beach2"
# A grid of buttons.
grid 3 3:
xfill True
yfill True
# Call make_button to show a particular button.
add g.make_button("dark", "gal-dark.png", xalign=0.5, yalign=0.5)
add g.make_button("dawn", "gal-dawn.png", xalign=0.5, yalign=0.5)
add g.make_button("end1", "gal-end1.png", xalign=0.5, yalign=0.5)
add g.make_button("end2", "gal-end2.png", xalign=0.5, yalign=0.5)
add g.make_button("end3", "gal-end3.png", xalign=0.5, yalign=0.5)
add g.make_button("end4", "gal-end4.png", xalign=0.5, yalign=0.5)
add g.make_button("dark mary", "gal-dark_mary.png", xalign=0.5, yalign=0.5)
add g.make_button("dawn mary", "gal-dawn_mary.png", xalign=0.5, yalign=0.5)
# The screen is responsible for returning to the main menu. It could also
# navigate to other gallery screens.
textbutton "Return" action Return() xalign 0.5 yalign 0.5
1) I do not have an ATL Transformation known as slowpan. (And all my attempts to make one have failed miserably.)
Code: Select all
g.button("dark")
g.unlock_image("bigbeach1")
g.transform(slowpan)
Code: Select all
# Call make_button to show a particular button.
add g.make_button("dark", "gal-dark.png", xalign=0.5, yalign=0.5)
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/screen_gallery.rpy", line 101, in python
AttributeError: 'ADVCharacter' object has no attribute 'make_button'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\execution.py", line 265, in run
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\ast.py", line 632, in execute
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\python.py", line 972, in py_exec_bytecode
File "common/_layout/screen_main_menu.rpym", line 11, in <module>
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\ui.py", line 237, in interact
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\core.py", line 1814, in interact
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\core.py", line 555, in replace_transient
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\core.py", line 825, in remove
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\core.py", line 753, in hide_or_replace
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\screen.py", line 178, in _hide
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\display\screen.py", line 247, in update
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\screenlang.py", line 1166, in __call__
File "J:\!Kenetic Novels\RenPy\renpy-6.13.12\renpy\python.py", line 972, in py_exec_bytecode
File "game/screen_gallery.rpy", line 101, in <module>
AttributeError: 'ADVCharacter' object has no attribute 'make_button'
Windows-7-6.1.7601-SP1
Ren'Py 6.13.12.1728
My Template 0.0
Please, please, please, with all due respect, could you post an entire working code, not just the relevant bits? Some of us are Beginners with coding. Unless you show us, we won't know where floating bits of code need to go. Nor can we tell when a chunk of extra coding is needed somewhere else to make something work.
I apologize for my ignorance, but I did use the search function, and all queries on making a gallery Screen come back to This code; a code I can't seem to make work.