[Solved] Gallery/curpage Syntax Error

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.
Post Reply
Message
Author
User avatar
XxrenxX
Veteran
Posts: 267
Joined: Tue Oct 02, 2012 2:40 am
Projects: Chasing
Deviantart: bara-ettie
Location: Canada
Contact:

[Solved] Gallery/curpage Syntax Error

#1 Post by XxrenxX »

So I found this gallery code, and it works perfectly but I wanted to implement curpages so everything is accessible through one menu. Upon adding in the curpages I get a syntax error.

Code: Select all

I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
  File "game/Gallery.rpy", line 27, in analyze_screen
    screen gallery():
  File "game/Gallery.rpy", line 27, in analyze
    screen gallery():
  File "game/Gallery.rpy", line 27, in analyze
    screen gallery():
  File "game/Gallery.rpy", line 36, in analyze
    grid gui.file_slot_cols gui.file_slot_rows:
  File "game/Gallery.rpy", line 36, in analyze
    grid gui.file_slot_cols gui.file_slot_rows:
  File "game/Gallery.rpy", line 43, in analyze
    if $ curpage == "CG 01":
SyntaxError: invalid syntax (game/Gallery.rpy, line 43)
re curpages not supported anymore or is there another way to go about doing this? I thought I might need to define $ curpage = "CG_01" so I have it in an init: block before my game starts in the script.

Code: Select all

init python:
    g = Gallery()
    g.transition = fade
    
    g.button("cg_gallery01")
    g.image("bg Park1 Purple")
    g.unlock("bg Park1 Purple")

screen gallery():
    tag menu
    add "gui/BG/Gallery.png"

    textbutton "Close" xpos 945 ypos 75 action Return()
    textbutton "CG 01" xpos 1068 ypos 254 action SetScreenVariable("curpage", "CG 01")
    textbutton "Scene" xpos 1068 ypos 294 action SetScreenVariable("curpage", "scenegallery")
    textbutton "Video" xpos 1068 ypos 334 action SetScreenVariable("curpage", "videogallery")

    grid gui.file_slot_cols gui.file_slot_rows:
        style_prefix "gslot"
        xpos 228
        ypos 144
        xspacing 37
        yspacing 13

        if $ curpage == "CG 01":
            add g.make_button("cg_gallery01","gui/GS/null.png")
Last edited by XxrenxX on Mon Apr 08, 2019 6:43 pm, edited 1 time in total.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Gallery/curpage Syntax Error

#2 Post by Enchant00 »

If you defined curpage in an init block before your game starts, then you should used SetVariable and not the SetScreenVariable since the variable was not defined under your screen gallery; unless if curpage is displayed on screen and defined by said screen then SetScreenVariable is correct.

Code: Select all

textbutton "CG 01" xpos 1068 ypos 254 action SetVariable("curpage", "CG 01")
Also, your conditional is wrong so remove the $ sign.

Code: Select all

if curpage == "CG 01":
            add g.make_button("cg_gallery01","gui/GS/null.png")
Last edited by Enchant00 on Mon Apr 08, 2019 6:43 pm, edited 1 time in total.

User avatar
XxrenxX
Veteran
Posts: 267
Joined: Tue Oct 02, 2012 2:40 am
Projects: Chasing
Deviantart: bara-ettie
Location: Canada
Contact:

Re: Gallery/curpage Syntax Error

#3 Post by XxrenxX »

Enchant00 wrote: Mon Apr 08, 2019 6:38 pm
Yup that fixed it. My fault for using an old code that use to work years ago xD

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Gallery/curpage Syntax Error

#4 Post by Enchant00 »

XxrenxX wrote: Mon Apr 08, 2019 6:43 pm
Enchant00 wrote: Mon Apr 08, 2019 6:38 pm
Yup that fixed it. My fault for using an old code that use to work years ago xD
Yeah that happens. There is a lot of good code out there and most of them aren't optimized for the current build of renpy.

User avatar
XxrenxX
Veteran
Posts: 267
Joined: Tue Oct 02, 2012 2:40 am
Projects: Chasing
Deviantart: bara-ettie
Location: Canada
Contact:

Re: Gallery/curpage Syntax Error

#5 Post by XxrenxX »

Enchant00 wrote: Mon Apr 08, 2019 6:44 pm Yeah that happens. There is a lot of good code out there and most of them aren't optimized for the current build of renpy.
Yeah I noticed. Most of my game I code from around 5 years ago (that worked fine at the time) but had to put the project on hold. Finally able to do it again to find out a bunch changed so here I am trying to understand the new builds and update what I can without breaking anything.

Post Reply

Who is online

Users browsing this forum: No registered users