Jump or call under define ?

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
Riky35800
Newbie
Posts: 5
Joined: Sat Feb 29, 2020 12:44 pm
Contact:

Jump or call under define ?

#1 Post by Riky35800 »

Hey! I was wondering if its possible to use call or jump under the def

Code: Select all

init -1 python:
    def HasName():
        if player == "Player":
            jump invalidname
But I get this error as I run the game

https://i.imgur.com/5E4LyOC.jpg

Code: Select all

File "game/screens.rpy", line 403: invalid syntax
            jump invalidname

Ren'Py Version: Ren'Py 6.99.12.4.2187

User avatar
renardjap
Regular
Posts: 75
Joined: Sun Aug 05, 2018 1:08 pm
Location: France ! Cocorico
Contact:

Re: Jump or call under define ?

#2 Post by renardjap »

Hello
I belive it's not possible because "jump" is a language from Ren'py and when you put the python: keyword that's mean you use the python language. I don't know what's the code of your label invalidname, but you must write your function under your "if condition".

Riky35800
Newbie
Posts: 5
Joined: Sat Feb 29, 2020 12:44 pm
Contact:

Re: Jump or call under define ?

#3 Post by Riky35800 »

Like this?

Code: Select all

init -1 python:
    def HasName():
        if player == "Player":
            "Invalid name!"
            renpy.quit()
This was the first thing I've tried, but there is no message comes up even with callscreen.
However the renpy.quit works underneath

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Jump or call under define ?

#4 Post by Alex »

Riky35800 wrote: Sat Feb 29, 2020 3:13 pm ..., but there is no message comes up ...
In python blocks of code you ought to use python equivalents of Ren'Py statements - https://www.renpy.org/doc/html/statemen ... lents.html

User avatar
renardjap
Regular
Posts: 75
Joined: Sun Aug 05, 2018 1:08 pm
Location: France ! Cocorico
Contact:

Re: Jump or call under define ?

#5 Post by renardjap »

Code: Select all

label start:

    "Welcome to the game"
    $ player = renpy.input("What's your name ? \n ")
    if player == "Player":
        "Invalid name!"
        $ renpy.quit()
    "Thank you [player]"

    return
Maybe something like this ???
It's not necessary to define a function for that, you can add it below the player input.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Jump or call under define ?

#6 Post by gas »

Code: Select all

init -1 python:
    def HasName():
        if player == "Player":
            renpy.jump ("invalidname")
renpy.jump() is the python equivalent of jump.
Python equivalents are used inside python blocks to emulate renpy statements (well, a bit more intricated than this, but that's the use logic).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

Riky35800
Newbie
Posts: 5
Joined: Sat Feb 29, 2020 12:44 pm
Contact:

Re: Jump or call under define ?

#7 Post by Riky35800 »

gas wrote: Sat Feb 29, 2020 5:48 pm

Code: Select all

init -1 python:
    def HasName():
        if player == "Player":
            renpy.jump ("invalidname")
renpy.jump() is the python equivalent of jump.
Python equivalents are used inside python blocks to emulate renpy statements (well, a bit more intricated than this, but that's the use logic).
That works well! Thank you so much you are a life saver.
The other solutions sadly didn't work for me. When I wrote some text under def its just not printed it. dunno why

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Jump or call under define ?

#8 Post by gas »

The text wasn't printed cause printing text such way is a renpy statement.
You need to use a python equivalent:

Code: Select all

renpy.say("Invalid name!")
What's inside a python block can't execute directly renpy statements. Renpy statements work only when inside a label.

Code: Select all

init -1 python:
    # this is a python block, you must use python statemente equivalents

label start:
    # this is a renpy block, you can use normal renpy statements
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

Post Reply

Who is online

Users browsing this forum: Andredron, Bing [Bot], geoWaffle