Help with renpy.variant function

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
Anastimafilia
Regular
Posts: 26
Joined: Mon May 30, 2022 3:43 pm
itch: anastimafilia
Discord: Anastimafilia#1400
Contact:

Help with renpy.variant function

#1 Post by Anastimafilia »

Hello! I need help with this code

Code: Select all

label start1:
    if renpy.variant("web"):
        jump passcheck
    else:
        jump start

label passcheck:
    call screen password_input()
    $ entered_password = _return

    if entered_password == "Helix":  
        "Password Accepted."
        jump start
    else:
        "Wrong password."
        jump passcheck  # Jump back to the start of the label, so they can try again.
I need this passcheck code to only work in the web version but it doesn't work for some reason

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Help with renpy.variant function

#2 Post by giorgi1111 »

What doesnot work? When you enter game with browser doesnot jumps passcheck?

User avatar
Anastimafilia
Regular
Posts: 26
Joined: Mon May 30, 2022 3:43 pm
itch: anastimafilia
Discord: Anastimafilia#1400
Contact:

Re: Help with renpy.variant function

#3 Post by Anastimafilia »

exactly, the passcheck label doesn't work in the web version

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Help with renpy.variant function

#4 Post by giorgi1111 »

Show screen code.if you return pass with action add check that pass and jump there straight in that action
And There are some limitations
https://www.renpy.org/doc/html/web.html

User avatar
Anastimafilia
Regular
Posts: 26
Joined: Mon May 30, 2022 3:43 pm
itch: anastimafilia
Discord: Anastimafilia#1400
Contact:

Re: Help with renpy.variant function

#5 Post by Anastimafilia »

Code: Select all

screen password_input():
    default entered_password = ""

    frame:
        xsize 560
        ysize 240
        xalign 0.5  # Centers the frame horizontally
        yalign 0.5  # Centers the frame vertically
        vbox:
            xalign .5
            yalign .5
            spacing 60
            input:
                value ScreenVariableInputValue("entered_password", returnable=True)

            textbutton "Submit" action Return(entered_password)
here's the code from screens, this is inside the input section

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Help with renpy.variant function

#6 Post by giorgi1111 »

if entered_password == "Helix":
---textbutton "submit":
------action Notify("Password Accepted."), Jump("start")

else:
---- textbutton "submit":
----------action Notify wrong password try again, jump passcheck


Corect code and remove ---- signs

User avatar
Anastimafilia
Regular
Posts: 26
Joined: Mon May 30, 2022 3:43 pm
itch: anastimafilia
Discord: Anastimafilia#1400
Contact:

Re: Help with renpy.variant function

#7 Post by Anastimafilia »

Code: Select all

label start1:
    if renpy.variant("web"):
        jump passcheck
    else:
        jump start

label passcheck:
    if entered_password == "Helix":
    textbutton "submit":
        action Notify("Password Accepted."), Jump("start")

    else:
    textbutton "submit":
        action Notify ("wrong password, try again"), jump ("passcheck")


label start:

    "The events and characters within this visual novel are completely fictitious and any resemblance to the real world is mere coincidence."
Like this?

User avatar
Anastimafilia
Regular
Posts: 26
Joined: Mon May 30, 2022 3:43 pm
itch: anastimafilia
Discord: Anastimafilia#1400
Contact:

Re: Help with renpy.variant function

#8 Post by Anastimafilia »

I'm getting errors btw

Code: Select all

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


File "game/script.rpy", line 53: if statement expects a non-empty block.
    if entered_password == "Helix":
                                   ^

File "game/script.rpy", line 54: end of line expected.
    textbutton "submit":
                       ^

File "game/script.rpy", line 57: expected statement.
    else:
        ^

File "game/script.rpy", line 58: end of line expected.
    textbutton "submit":
                       ^

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Help with renpy.variant function

#9 Post by giorgi1111 »

No in screen you have textbutonsubmit remove it and after value ScreenVariableInputValue("entered_password", returnable=True) use
if entered_password == "Helix":
textbutton "submit":
action Notify("Password Accepted."), Jump("start")

else:
textbutton "submit":
action Notify ("wrong password, try again"), jump ("passcheck")
After if and after else corect add some space before textbutton

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3812
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help with renpy.variant function

#10 Post by Imperf3kt »

For Web checks, try the variant "renpy.emscripten" rather than "Web"
https://www.renpy.org/doc/html/other.ht ... emscripten
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]