• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

VN Ren'Py How to hide textbox (persistent)

iOtero

Active Member
Aug 4, 2020
924
1,458
Hi, I want to make an option in the game that allows you to see the dark background of the texbox or not.
I have taken the following steps:

In script.rpy:

Code:
label splashscreen:
    $ ChangeTBox()
    return
In screens.rpy:

Code:
init -1 python:
    if persistent.tbox is None:
        persistent.tbox = False

    def ChangeTBox():
        gui.tbox = persistent.tbox
In screens.rpy -screen preferences()-

Code:
vbox:
    style_prefix "radio"
    label _("Textbox")
    textbutton _("Yes") action [SetVariable("persistent.tbox", True), ChangeTBox]
    textbutton _("No") action [SetVariable("persistent.tbox", False), ChangeTBox]
and:

Code:
style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height
    if gui.tbox:
        background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
And I get the following error:

Code:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 155: end of line expected.
    if gui.tbox:
    ^

Ren'Py Version: Ren'Py 7.3.5.606
Mon Dec 28 15:25:56 2020

What am I doing wrong? Thank you for your help.
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,040
3,118
you want to us ConditionSwitch

Code:
default show_window = False

vbox:
    style_prefix "radio"
    label _("Textbox")
    textbutton _("Yes") action SetVariable("show_window", True)
    textbutton _("No") action SetVariable("show_window", False)


style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background ConditionSwitch('False', Null,
                            'True', Image("gui/textbox.png", xalign=0.5, yalign=1.0))
 

Reaver

Active Member
May 31, 2017
711
621
This is interesting, but for those of us that don't understand coding is there a quick and dirty file we can add to the game folder and have it remove the background color?
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,040
3,118
This is interesting, but for those of us that don't understand coding is there a quick and dirty file we can add to the game folder and have it remove the background color?
it a image not a color there is a way to do it but that's if anyone wants to do it
 

iOtero

Active Member
Aug 4, 2020
924
1,458
you want to us ConditionSwitch

Code:
default show_window = False

vbox:
    style_prefix "radio"
    label _("Textbox")
    textbutton _("Yes") action SetVariable("show_window", True)
    textbutton _("No") action SetVariable("show_window", False)


style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background ConditionSwitch('False', Null,
                            'True', Image("gui/textbox.png", xalign=0.5, yalign=1.0))
Thanks, but it doesn't work.