Wrongly shown variables and display hidden variables

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.
Message
Author
JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Wrongly shown variables and display hidden variables

#1 Post by JanusP »

Display shows (disabled) text when its not supposed to show and be system indicator only.
For the title, it shows as [d20roll] and [TD] instead of the info in variables. Trying to make it show assigned input variables.

Code: Select all

label start:
label choice1:
    "Congratulations to your initiation, there are basic questions needed for authentication"
    $ playerlastname = renpy.input("Enter surname")
    $ playerlastname = playerlastname.strip()
    $ player1stname = renpy.input("Enter Legal name")
    $ player1stname = player1stname.strip()
    $ player_name = player1stname+" "+ playerlastname
    $ player_name = player_name.strip()
    if player_name == "":
        $ player_name="Potential"
	$ donated = renpy.input("Yes or No,Have you donated yet?")
    	if [donated] == "Yes":
		$d20roll = renpy.random.randint(1, 9000)
    	else:
		$d20roll = renpy.random.randint(9001, 10000)
label donum:
	$ donatenum = renpy.input("How much have you donated?")
	if donatenum <= 0:
		$ t = "F2watchton"
	elif donatenum <= 500:
		$ t = "Minnow"
	elif (donatenum > 500) and (donatenum <= 1000):
		$ t = "Goldfish"
	elif (donatenum > 1000) and (donatenum <= 150000):
		$ t= "Swordfish"
	elif (donatenum > 15000) and (donatenum <= 20000):
		$ t = "Dolphin"
	elif (donatenum > 20000) and (donatenum <= 25000):
		$ t = "Whale"
	elif (donatenum > 25000) and (donatenum <= 30000):
		$ t = "Leviathan"
	else:
		$ t= "Cthulu"
menu final:
    "Confirm your information"

    "[age] (Disabled)":
        pass
    "[country] (Disabled)":
        pass
    "[work] (Disabled)":
        pass
    "[hear] (Disabled)":
        pass
    "[love] (Disabled)":
        pass
    "[how] (Disabled)":
        pass
    "[why] (Disabled)":
        pass
    "[react](disabled)":
        pass
    "[donateanum] (Disabled)":
        pass
    "Yes all is correct":
        jump title
menu title:
    "show title?"

    "Yes":
        jump final2
    "No":
        jump final1

label final1:
    $ TD = [t]+" "+[d20roll]
    $ TD = TD.strip()
    "Congratulations # [d20roll] and we hope to see you more in the stream."
label final2:
    "Congratulations # [TD] and we hope to see you more in the stream"
return

###############<screens.rpy>################################################
screen choice:

    window:
        style "menu_window"
        xalign 0.9
        yalign 0.5

        vbox:
            style "menu"
            spacing 2

            for caption, action, chosen in items:

                if action:

                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")
                        button:
                            action None
                            style "menu_choice_button"

                            text caption style "menu_choice"
                    else:
                        button:
                            action action
                            style "menu_choice_button"

                            text caption style "menu_choice"

                else:
                    text caption style "menu_caption"

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#2 Post by midgethetree »

Python is case-sensitive and you use both "Disabled" and "disabled" in different parts of the code. You should change them all to be the exact same case (all "disabled" or all "Disabled").

Your other problem is coming from trying to use [] syntax for interpolation in python, where [] actually means a list. $ TD = [t]+" "+[d20roll] should instead be $ TD = t+" "+str(d20roll). Alternatively just use "Congratulations # [t] [d20roll] ..." instead of "Congratulations # [TD]" and cut out TD entirely.

On another note, defining TD in label final1 but only using it in final2 is a bad idea... if someone answers yes to the title menu question they'll skip the final1 label and so TD won't be defined and they'll get an error. If you do keep the TD variable move its definition to where it's actually used.

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#3 Post by JanusP »

midgethetree wrote: Sun Jan 31, 2021 1:52 am Python is case-sensitive and you use both "Disabled" and "disabled" in different parts of the code. You should change them all to be the exact same case (all "disabled" or all "Disabled").

Your other problem is coming from trying to use [] syntax for interpolation in python, where [] actually means a list. $ TD = [t]+" "+[d20roll] should instead be $ TD = t+" "+str(d20roll). Alternatively just use "Congratulations # [t] [d20roll] ..." instead of "Congratulations # [TD]" and cut out TD entirely.

On another note, defining TD in label final1 but only using it in final2 is a bad idea... if someone answers yes to the title menu question they'll skip the final1 label and so TD won't be defined and they'll get an error. If you do keep the TD variable move its definition to where it's actually used.
This worked to an extent, problem is now it shows clickable choices with (disabled) and an overlay on top of the text but working correctly. I want their role to be switched so it shows as normal choices but is unclickable when its set as disabled and to get rid of black overlay with text.

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#4 Post by midgethetree »

Are you saying choices with (disabled) are using the insensitive button text color but you want them to use the normal text color? You could style them like normal text instead, just change the style from 'menu_choice' to 'menu_disabled_choice' or whatever and make sure not to give the menu_disabled_choice style the insensitive_color property.

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#5 Post by JanusP »

midgethetree wrote: Mon Feb 01, 2021 12:34 am Are you saying choices with (disabled) are using the insensitive button text color but you want them to use the normal text color? You could style them like normal text instead, just change the style from 'menu_choice' to 'menu_disabled_choice' or whatever and make sure not to give the menu_disabled_choice style the insensitive_color property.
With these adjustments I've managed to make them into a choice format except they still appear as a translucent overlay on top the the same text; but as normal choices. Not sure how to eliminate the overlay without getting rid of disabled format.

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#6 Post by midgethetree »

...I'm not sure I understand what you're seeing vs. what you want. Can you better explain what you mean by this translucent overlay, maybe show a picture? Maybe share the code you're using for the choice screen styles?

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#7 Post by JanusP »

midgethetree wrote: Tue Feb 02, 2021 2:11 pm ...I'm not sure I understand what you're seeing vs. what you want. Can you better explain what you mean by this translucent overlay, maybe show a picture? Maybe share the code you're using for the choice screen styles?
In the script, its a normal choice format
This is what it looks like:
https://imgur.com/a/rGg8DHb

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#8 Post by midgethetree »

Well first of all, when I was suggesting adding a separate disabled style, I meant specifically the ones with (disabled) in them so they could be styled differently from normal choice buttons. So past the 'else' statement they'd go back to normal styles. It now seems like what you're disliking is not related to the choice button styles but the window styles, so that might've been unnecessary altogether.

What I can now see is the problem, is 1) the window has a background. You still haven't shown the definition for the nvl_menu style, but presumably you do have it written somewhere in your screens.rpy and can add the line 'background none' to it or change its current background [whatever] line to background none.

You've also added back the original vbox above the window, so every choice is shown twice. Either get rid of the vbox, or move your code for checking if it's disabled to the vbox and get rid of the window (which hey, would also solve the background issue).

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#9 Post by JanusP »

midgethetree wrote: Tue Feb 02, 2021 7:18 pm Well first of all, when I was suggesting adding a separate disabled style, I meant specifically the ones with (disabled) in them so they could be styled differently from normal choice buttons. So past the 'else' statement they'd go back to normal styles. It now seems like what you're disliking is not related to the choice button styles but the window styles, so that might've been unnecessary altogether.

What I can now see is the problem, is 1) the window has a background. You still haven't shown the definition for the nvl_menu style, but presumably you do have it written somewhere in your screens.rpy and can add the line 'background none' to it or change its current background [whatever] line to background none.

You've also added back the original vbox above the window, so every choice is shown twice. Either get rid of the vbox, or move your code for checking if it's disabled to the vbox and get rid of the window (which hey, would also solve the background issue).
In screen rpy there isn't a nvl menu and I don't understand the explanation enough to attempt it. Could you explain how to manipulate the background or get rid of the window/vbox?
When i try moving the disabled script around it leads to results like this:
https://imgur.com/a/tdYi0HX

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#10 Post by midgethetree »

You'll see in your code you have

Code: Select all

vbox:
    for i in items:
        textbutton i.caption action i.action
followed by your disabled code, but also

Code: Select all

window:
    style "menu_window"
    xalign 1.0
    yalign 0.5
    vbox:
        style "menu"
        spacing 2
        for caption, action, chosen in items:
followed by your disabled code... so basically every choice is getting shown twice, because you're doing 'for _ in items' twice and in each loop adding buttons.

Either delete the entire vbox chunk or the entire window chunk, and paste the resulting code into a post here so I can actually copy it if you need further help modifying it.

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#11 Post by JanusP »

midgethetree wrote: Thu Feb 04, 2021 2:09 am You'll see in your code you have

Code: Select all

vbox:
    for i in items:
        textbutton i.caption action i.action
followed by your disabled code, but also

Code: Select all

window:
    style "menu_window"
    xalign 1.0
    yalign 0.5
    vbox:
        style "menu"
        spacing 2
        for caption, action, chosen in items:
followed by your disabled code... so basically every choice is getting shown twice, because you're doing 'for _ in items' twice and in each loop adding buttons.

Either delete the entire vbox chunk or the entire window chunk, and paste the resulting code into a post here so I can actually copy it if you need further help modifying it.
This error occurs at the 2nd part for displaying input:

Code: Select all

screen choice(items):
    style_prefix "choice"
    window:
        style "menu_window"
        xalign 1.0
        yalign 0.5
        vbox:
            style "menu"
            spacing 2
            for caption, action, chosen in items:
                if action:
                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")
                        button:
                            action None
                            style "menu_disabled_choice_button"
                            text caption style "menu_disabled_choice"
                    else:
                        button:
                            action action
                            style "menu_disabled_choice_button"

                            text caption style "menu_disabled_choice"
                else:
                    text caption style "menu_caption"
Which leads to this error in the display info section:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 75, in script
    menu final:
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 208, in execute
    window:
  File "game/screens.rpy", line 212, in execute
    vbox:
  File "game/screens.rpy", line 215, in execute
    for caption, action, chosen in items:
  File "game/screens.rpy", line 216, in execute
    if action:
  File "game/screens.rpy", line 217, in execute
    if " (disabled)" in caption:
  File "game/screens.rpy", line 219, in execute
    button:
  File "game/screens.rpy", line 222, in execute
    text caption style "menu_disabled_choice"
NameError: Name 'description' is not defined.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 75, in script
    menu final:
  File "renpy/ast.py", line 1642, in execute
    choice = renpy.exports.menu(choices, self.set, args, kwargs, item_arguments)
  File "renpy/exports.py", line 1029, in menu
    rv = renpy.store.menu(new_items)
  File "renpy/exports.py", line 1265, in display_menu
    rv = renpy.ui.interact(mouse='menu', type=type, roll_forward=roll_forward)
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3007, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3418, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/screen.py", line 432, in visit_all
    callback(self)
  File "renpy/display/core.py", line 3418, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/screen.py", line 443, in per_interact
    self.update()
  File "renpy/display/screen.py", line 631, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 208, in execute
    window:
  File "game/screens.rpy", line 212, in execute
    vbox:
  File "game/screens.rpy", line 215, in execute
    for caption, action, chosen in items:
  File "game/screens.rpy", line 216, in execute
    if action:
  File "game/screens.rpy", line 217, in execute
    if " (disabled)" in caption:
  File "game/screens.rpy", line 219, in execute
    button:
  File "game/screens.rpy", line 222, in execute
    text caption style "menu_disabled_choice"
  File "renpy/text/text.py", line 1525, in __init__
    self.set_text(text, scope, substitute)
  File "renpy/text/text.py", line 1644, in set_text
    i, did_sub = renpy.substitutions.substitute(i, scope, substitute)
  File "renpy/substitutions.py", line 270, in substitute
    s = formatter.vformat(s, (), kwargs)
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 563, in vformat
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 585, in _vformat
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 646, in get_field
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 605, in get_value
  File "renpy/substitutions.py", line 228, in __getitem__
    raise NameError("Name '{}' is not defined.".format(key))
NameError: Name 'description' is not defined.
I want to make it look the 2nd image where the text is centered and looks like the normal choice format.
https://imgur.com/a/t5eHGOh

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#12 Post by midgethetree »

If you want it to be centered and look like the default choice GUI, keeping the vbox would've been better:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            if " (disabled)" in i.caption:
                $ caption = i.caption.replace(" (disabled)", "")
                textbutton caption action None
            else:
                textbutton caption action i.action
The error looks like you tried to do something like

Code: Select all

menu:
    "[description] (disabled)"
but never defined "description". Make sure all the variables you're showing are defined beforehand.

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#13 Post by JanusP »

midgethetree wrote: Thu Feb 04, 2021 7:24 pm If you want it to be centered and look like the default choice GUI, keeping the vbox would've been better:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            if " (disabled)" in i.caption:
                $ caption = i.caption.replace(" (disabled)", "")
                textbutton caption action None
            else:
                textbutton caption action i.action
The error looks like you tried to do something like

Code: Select all

menu:
    "[description] (disabled)"
but never defined "description". Make sure all the variables you're showing are defined beforehand.
So trying that I get on the 1st choice:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 24, in script
    menu choiceb:
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 209, in execute
    vbox:
  File "game/screens.rpy", line 210, in execute
    for i in items:
  File "game/screens.rpy", line 211, in execute
    if " (disabled)" in i.caption:
  File "game/screens.rpy", line 215, in execute
    textbutton caption action i.action
  File "game/screens.rpy", line 215, in <module>
    textbutton caption action i.action
NameError: name 'caption' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 24, in script
    menu choiceb:
  File "renpy/ast.py", line 1642, in execute
    choice = renpy.exports.menu(choices, self.set, args, kwargs, item_arguments)
  File "renpy/exports.py", line 1029, in menu
    rv = renpy.store.menu(new_items)
  File "renpy/exports.py", line 1265, in display_menu
    rv = renpy.ui.interact(mouse='menu', type=type, roll_forward=roll_forward)
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3007, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3418, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/screen.py", line 432, in visit_all
    callback(self)
  File "renpy/display/core.py", line 3418, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/screen.py", line 443, in per_interact
    self.update()
  File "renpy/display/screen.py", line 631, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 206, in execute
    screen choice(items):
  File "game/screens.rpy", line 209, in execute
    vbox:
  File "game/screens.rpy", line 210, in execute
    for i in items:
  File "game/screens.rpy", line 211, in execute
    if " (disabled)" in i.caption:
  File "game/screens.rpy", line 215, in execute
    textbutton caption action i.action
  File "game/screens.rpy", line 215, in <module>
    textbutton caption action i.action
NameError: name 'caption' is not defined

Windows-10-10.0.19041
Ren'Py 7.4.2.1292
test 1.0
Thu Feb  4 16:47:16 2021
then changing to:

Code: Select all

screen choice:
    style_prefix "choice"

    vbox:
        for i in items:
            if i.action:
                if " (disabled)" in i.caption:
                    textbutton i.caption.replace(" (disabled)", "")
                else:
                    textbutton i.caption action i.action
            else:
                textbutton i.caption
works till I get to display info which results in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 75, in script
    menu final:
  File "game/screens.rpy", line 206, in execute
    screen choice:
  File "game/screens.rpy", line 206, in execute
    screen choice:
  File "game/screens.rpy", line 209, in execute
    vbox:
  File "game/screens.rpy", line 210, in execute
    for i in items:
  File "game/screens.rpy", line 211, in execute
    if i.action:
  File "game/screens.rpy", line 212, in execute
    if " (disabled)" in i.caption:
  File "game/screens.rpy", line 213, in execute
    textbutton i.caption.replace(" (disabled)", "")
NameError: Name 'description' is not defined.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 75, in script
    menu final:
  File "renpy/ast.py", line 1642, in execute
    choice = renpy.exports.menu(choices, self.set, args, kwargs, item_arguments)
  File "renpy/exports.py", line 1029, in menu
    rv = renpy.store.menu(new_items)
  File "renpy/exports.py", line 1265, in display_menu
    rv = renpy.ui.interact(mouse='menu', type=type, roll_forward=roll_forward)
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3007, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3418, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 566, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/screen.py", line 432, in visit_all
    callback(self)
  File "renpy/display/core.py", line 3418, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/screen.py", line 443, in per_interact
    self.update()
  File "renpy/display/screen.py", line 631, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 206, in execute
    screen choice:
  File "game/screens.rpy", line 206, in execute
    screen choice:
  File "game/screens.rpy", line 209, in execute
    vbox:
  File "game/screens.rpy", line 210, in execute
    for i in items:
  File "game/screens.rpy", line 211, in execute
    if i.action:
  File "game/screens.rpy", line 212, in execute
    if " (disabled)" in i.caption:
  File "game/screens.rpy", line 213, in execute
    textbutton i.caption.replace(" (disabled)", "")
  File "renpy/ui.py", line 992, in _textbutton
    text = renpy.text.text.Text(label, style=text_style, substitute=substitute, scope=scope, **text_kwargs)
  File "renpy/text/text.py", line 1525, in __init__
    self.set_text(text, scope, substitute)
  File "renpy/text/text.py", line 1644, in set_text
    i, did_sub = renpy.substitutions.substitute(i, scope, substitute)
  File "renpy/substitutions.py", line 270, in substitute
    s = formatter.vformat(s, (), kwargs)
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 563, in vformat
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 585, in _vformat
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 646, in get_field
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 605, in get_value
  File "renpy/substitutions.py", line 228, in __getitem__
    raise NameError("Name '{}' is not defined.".format(key))
NameError: Name 'description' is not defined.

Windows-10-10.0.19041
Ren'Py 7.4.2.1292
test 1.0
Thu Feb  4 16:49:02 2021
But not quite sure what to define it as.

User avatar
midgethetree
Regular
Posts: 39
Joined: Wed Dec 30, 2020 3:51 pm
Completed: Back When, The Mother of Pearls, various jam games
Projects: When Everyone's Watching, Deliberation
Github: midgethetree
itch: midge-the-tree
Discord: rainafc#3353
Contact:

Re: Wrongly shown variables and display hidden variables

#14 Post by midgethetree »

Whoops, I meant to say

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            if " (disabled)" in i.caption:
                $ caption = i.caption.replace(" (disabled)", "")
                textbutton caption action None
            else:
                textbutton i.caption action i.action
Although what you changed it to is fine too.

What you define description as depends on what text you intended to show when you used [description].

JanusP
Newbie
Posts: 8
Joined: Tue Apr 07, 2020 9:11 pm
Contact:

Re: Wrongly shown variables and display hidden variables

#15 Post by JanusP »

midgethetree wrote: Thu Feb 04, 2021 10:11 pm Whoops, I meant to say

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            if " (disabled)" in i.caption:
                $ caption = i.caption.replace(" (disabled)", "")
                textbutton caption action None
            else:
                textbutton i.caption action i.action
Although what you changed it to is fine too.

What you define description as depends on what text you intended to show when you used [description].
I don't understand what you mean, can you give an example of with error and one without?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], IrisColt