[SOLVED] expected 'label_name_declare' not found

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
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

[SOLVED] expected 'label_name_declare' not found

#1 Post by Kaji »

I'm currently working on adding a "Translator Note" button to my game that I can display when there's content to show and hide when there isn't.

The current plan is to set it up so that a translator_note variable can be set and unset, telling the system to show the button. Tapping the button would then bring up a modal screen which would set up the overall layout and then loading the actual content of the note by jumping to a label contained within the translator_note variable.

Here's my code so far. I've got the following addition to the say() screen to create the button:

Code: Select all

screen say(who, what):
    ###### START TRANSLATOR NOTE BUTTON
    button:
        action Show("translator_note", dissolve)
        xalign 0.9
        yalign 0.05
        background "#dddddd"
        xsize 250
        ysize 200
        vbox: # yalign 1 seems to get ignored
            xalign 0.5 yalign 0.5
            text "{size=-8}Translator\nNote{/size}" color "#0000008f"
    ###### END TRANSLATOR NOTE BUTTON

    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"
And here's the code to create the translator_note() screen:

Code: Select all

screen translator_note():
    modal True #The screen has to be modal, right? So nothing below it can be clicked
    button: ## Making the whole area dismissable by simply touching it anywhere
        action Hide('translator_note', dissolve) #This is the "Done" button, with the Hide() screen action, wich in this case hides the very screen where it is created.
        xalign 0.5 yalign 0.5
        background "#000a0280" # sumiiro @50%
        xsize 1920
        ysize 1080

        frame:
            xalign 0.5 yalign 0.5
            background "#fcfaf2" # shironeri
            xmaximum 800

            vbox:
                $ renpy.jump(translator_note_test)


label "translator_note_test":
    text 'A Translator Note Here' color "#171412" # kokushoku
Parsing the script is failing with the following:
expected 'label_name_declare' not found. label->"translator_note_test"
Is there a better way to call blocks of layout code to drop inside of another layout? Or is the current method viable and I'm just calling it wrong? I know it didn't like just calling jump translator_note_text directly, which is why I tried the $ renpy.jump(translator_note_text) method above.
Last edited by Kaji on Thu Dec 01, 2022 9:30 pm, edited 1 time in total.

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: expected 'label_name_declare' not found

#2 Post by bonnie_641 »

Kaji wrote: Thu Dec 01, 2022 6:08 pm I'm currently working on adding a "Translator Note" button to my game that I can display when there's content to show and hide when there isn't.

The current plan is to set it up so that a translator_note variable can be set and unset, telling the system to show the button. Tapping the button would then bring up a modal screen which would set up the overall layout and then loading the actual content of the note by jumping to a label contained within the translator_note variable.

Here's my code so far. I've got the following addition to the say() screen to create the button:

Code: Select all

(...)

            vbox:
                $ renpy.jump(translator_note_test)
This reminds me of a code I read some time ago.

The "vbox" doesn't work with $renpy.jump().
Did you try it with "textbutton"?

Code: Select all


            vbox:
                textbutton "Translator here" action Jump("translator_note_test")
Last edited by bonnie_641 on Thu Dec 01, 2022 6:35 pm, edited 2 times in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

Re: expected 'label_name_declare' not found

#3 Post by Kaji »

bonnie_641 wrote: Thu Dec 01, 2022 6:27 pm
Kaji wrote: Thu Dec 01, 2022 6:08 pm I'm currently working on adding a "Translator Note" button to my game that I can display when there's content to show and hide when there isn't.

The current plan is to set it up so that a translator_note variable can be set and unset, telling the system to show the button. Tapping the button would then bring up a modal screen which would set up the overall layout and then loading the actual content of the note by jumping to a label contained within the translator_note variable.

Here's my code so far. I've got the following addition to the say() screen to create the button:

Code: Select all

(...)

            vbox:
                $ renpy.jump(translator_note_test)
This reminds me of a code I read some time ago.

The "vbox" doesn't work with $renpy.jump().
Did you try it with "textbutton"?

Code: Select all


            vbox:
                textbutton "Translator here" action Jump("translator_note_test")
Thanks for the suggestion! I tried replacing that part of my code with yours and it's producing the same error

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: expected 'label_name_declare' not found

#4 Post by bonnie_641 »

Kaji wrote:

Code: Select all

label "translator_note_test":
    text 'A Translator Note Here' color "#171412" # kokushoku
Text belongs to the screen language, so it does not correspond to label

In this case use a custom character

Code: Select all

define e = Character("Eileen", who_color="#171412")

label start:
    show screen translator_note()
    "..."
    
label translator_note_test:
    e "A Translator Note Here"
    return
    
However, you probably wanted a screen, didn't you?

Code: Select all

screen translator_note_test:
    text 'A Translator Note Here' color "#171412" # kokushoku
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: expected 'label_name_declare' not found

#5 Post by bonnie_641 »

Kaji wrote: Thu Dec 01, 2022 6:08 pm ...

Code: Select all

# (...)
frame:
            background "#fcfaf2" # shironeri
            xmaximum 800
            xalign 0.5 yalign 0.5
            has vbox:  ########################################################## :D  :D  :D 
                textbutton "Click here :D"  action Show("translator_note_test") ####### :D  :D  :D 
            
            
        

        

label start:
    show screen translator_note()
    "..."
    
screen  translator_note_test():
    text "A Translator Note Here" color "#ff0"  align(0.5,0.7)

Is this what you wanted? I hope so :D
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

Re: expected 'label_name_declare' not found

#6 Post by Kaji »

bonnie_641 wrote: Thu Dec 01, 2022 7:29 pm
Kaji wrote: Thu Dec 01, 2022 6:08 pm ...

Code: Select all

# (...)
frame:
            background "#fcfaf2" # shironeri
            xmaximum 800
            xalign 0.5 yalign 0.5
            has vbox:  ########################################################## :D  :D  :D 
                textbutton "Click here :D"  action Show("translator_note_test") ####### :D  :D  :D 
            
            
        

        

label start:
    show screen translator_note()
    "..."
    
screen  translator_note_test():
    text "A Translator Note Here" color "#ff0"  align(0.5,0.7)

Is this what you wanted? I hope so :D
I had a bit of trouble figuring out how to make what you were suggesting work, but along the way it led me to something else that may be more ideal. Thanks for helping me think through the problem!

As you suggested, perhaps just invoking screens directly would be a better way to go. I was a bit hesitant to do that at first because I wasn't sure how to do that on a dynamic basis until I realized that Show() and Hide() both take variables corresponding to the name of the screen function.

Part of the reason I'd been avoiding screens for everything at first was that I was concerned about constantly having to redo the setup on things and missing something along the way, causing inconsistency (or worse, making it hard to update should I decide to change the look of things down the line). But by playing with styles a bit we can now do the following:

Code: Select all

## Define styles to attach to the button and frame so that we don't have to put them in manually every time
style tn_button is button:
    xalign 0.5 yalign 0.5
    background "#000a0280" # sumiiro @50%
    xsize 1920
    ysize 1080

style tn_frame is frame:
    xalign 0.5 yalign 0.5
    background "#fcfaf2" # shironeri
    xmaximum 800

## Name of the screen is unique to the note, hence the generated identifier at the end
screen translator_note_1e561f():
    modal True
    button style "tn_button": ## Define the button with two lines instead of five (one for the action, below)
        action Hide('translator_note_1e561f', dissolve) # Tap anywhere on the screen to dismiss the note

        frame style "tn_frame": ## One-line definition for the frame as well, allowing us to quickly jump to the meat of our note, below
            vbox:
                ## Note content below
                text 'A Translator Note Here' color "#171412" # kokushoku

### With that set the code can be invoked as follows:
screen say(who, what):
    ###### START TRANSLATOR NOTE BUTTON
    default translator_note = "" ## Prevent errors for being undefined

    if (translator_note != ""):
        button:
            action Show(translator_note, dissolve)
            xalign 0.9
            yalign 0.05
            background "#dddddd"
            xsize 250
            ysize 200
            vbox: # yalign 1 seems to get ignored
                xalign 0.5 yalign 0.5
                text "{size=-8}Translator\nNote{/size}" color "#0000008f"
    ###### END TRANSLATOR NOTE BUTTON

    style_prefix "say"


#### From there, in the script you would let it know there's a note to show by setting translator_note, like so:
$ translator_note = "translator_note_1e561f" ## Show Note
$ translator_note = "" ## Hide Note
...At least, it *seems* like that should work. Everything works except setting the variable at the end, it seems...
  • Making it a Python call ($ translator_note = "note_label") just seems to get ignored
  • The same method without the dollar sign (translator_note = "note_label") produces an "expected statement" error
  • Changing it to SetVariable (SetVariable('translator_note', "translator_note")) also produces the "expected statement" error
So it seems we're much closer now, but still need to figure out that last little bit...

User avatar
Kaji
Regular
Posts: 87
Joined: Thu Nov 17, 2022 10:17 pm
Github: Kaji01
Discord: Kaji#7767
Contact:

Re: [SOLVED] expected 'label_name_declare' not found

#7 Post by Kaji »

OK, figured out the issue! I was defining the default for translator_note on the say screen instead of in the global scope (e.g. right before label start:). Putting it there caused the code as shown above to work.

Bonnie_641, thanks for helping!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]