If command combined with jump

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
SiriWesen
Newbie
Posts: 7
Joined: Tue Oct 11, 2011 6:44 am
Location: Germany
Contact:

If command combined with jump

#1 Post by SiriWesen » Tue Oct 11, 2011 7:06 am

Yeah, okay.
So I started working on a VisualNovel because of a school project these days.
So far I had no real problems, but now there's a thing of which I can't find a suitable explanation for and I tried already to figure it out myself.

The user has to find a way into a castle. The user is asked wether he wants to go to the front gate where guards are standing or if he wants to search for another entrance.
Let's assume he decides to walk to the gate, where the user is asked, wether he wants to talk to the guards or if he wants to knock them out.
IF he chooses to talk to them, the guards will not open the gate and another menu appears.
Knock the guards out or find another entrance.
When the user decides to find another entrance he gets the menu to try to sneak inside or to knock the guard out and then go into the dungeon.
The user decides to sneak into the castle.

And what I want to do is, that the game jumps to a different label, when the user has talked before to the guards of the castle. If he decides in the beginning to find another entrance and then wants to sneak in, it jumps to label a, if he talked to the guards it jumps to label b. although you made the same choice in the last menu.
I hope you get what I mean.
Two ways in one choice, based on what happened before. I tried doing it myself, but it isn't working, and I don't know why.

So, this is the menu where I defined the if thing. The Novel's Language is German, so you might understand not a single word of the content, but I think, that is not important at all.
menu:
"Die Wachen beseitigen":
s "Euer schlimmster Alptraum!"
jump k_o
"Reden":
$ gift = "reden_mit_wache"
"Vielleicht sollte ich erst einmal mit Reden mein Glück versuchen."
jump wachen_reden
menu:
"Vorbeischleichen":
"Also versuchte ich mich an der wache vorbeizuschleichen."
if gift == "reden_mit_wache"
jump erwischt
jump hof_des_schlosses
"Wache ausschalten":
"Man konnte ja nie wissen, besser ich schaltete diese Wache aus."
jump hof_des_schlosses
I already tried lots of ways to combine this command and stuff and I'm pretty damn sure I made no other mistake, it has to be the gift thing...

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: If command combined with jump

#2 Post by DragoonHP » Tue Oct 11, 2011 9:07 am

SiriWesen wrote:The Novel's Language is German, so you might understand not a single word of the content, but I think, that is not important at all.
What's the worry when Google is here... :-p

The code should look something like this:

Code: Select all

label castleEntrance:
    "Should I go and talk to Guards?"
    menu:
        "Go to the entrance and talk to Guards.":
            "Dialogue goes here."
            jump Talked_to_Guard
        "Search for another entrance.":
            "Dialogue goes here."
            jump fail
            
label Talked_to_Guard:
    menu:
        "Talk to the Guard":
            "Dialogue goes here."
            menu:
                "Knock the Guard out":
                    "Dialogue goes here."
                    jump something
                "Find another way.":
                    "Dialogue goes here."
                    jump cleared
        "Knock the Guard out":
            "Dialogue goes here."
            jump fail
        "Find another way":

label fail:
    menu:
        "Die Wachen beseitigen":
            s "Euer schlimmster Alptraum!"
            jump k_o
       "Reden":
           $ gift = "reden_mit_wache"
           "Vielleicht sollte ich erst einmal mit Reden mein Glück versuchen."
           jump wachen_reden
           
label cleared:
    menu:
        "Vorbeischleichen":
            "Also versuchte ich mich an der wache vorbeizuschleichen."
            if gift == "reden_mit_wache"
            jump erwischt
        "Wache ausschalten":
            "Man konnte ja nie wissen, besser ich schaltete diese Wache aus."
            jump hof_des_schlosses
Some assumptions I made...
--> Label A results to Game Over so that's why the fail...
--> Label B results to the clearance...
--> You were asking about this... :-p

You can also use variable to do this, where you will have to use if.. else statement with the variable...

SiriWesen
Newbie
Posts: 7
Joined: Tue Oct 11, 2011 6:44 am
Location: Germany
Contact:

Re: If command combined with jump

#3 Post by SiriWesen » Tue Oct 11, 2011 12:28 pm

Thx for the reply.

Well, I tried the thing you wrote with a short demo script and did not work. Maybe it's because I got an older Version of Ren'Py ? ( 6.10.2e)

In the end this part is not really relevant to the story, but I thought it would be more entertaining having it this way. So it matters if you talked to the guards they'll spot you trying to sneak in and if you haven't they would not spot you. I just thought this would be nice to have as some sort of "personal highlight" (< exaggerated expression).

Oh, and when it comes to label A, well, i like a game more when I can decide by myself how to enter the castle. ^^ So you are free to decide wether you knock them out or sneak in. (it's just, that the user does not know that...).

Maybe I can figure out another way how to have two different reactions. I actually think I thought of this problem in a too complicated why, I just came up with an idea how to do this. ^^' Hope it will work this time.

Thank you for your help, it was useful in the end.

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: If command combined with jump

#4 Post by DragoonHP » Tue Oct 11, 2011 12:50 pm

It does not matter, it should work on any Ren'Py version... it's one of the most basic feature of Ren'Py...

Can you tell me what was wrong with it?

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: If command combined with jump

#5 Post by Camille » Tue Oct 11, 2011 1:13 pm

I've corrected DragoonHP's code, which had a few missing colons and indentation errors. I think this should now work. As he said, it's one of the most basic Ren'Py features, so it should work no matter what version you have. (though I highly recommend you update to the latest version, as it fixes many problems and 6.13 runs much better)

Code: Select all

label castleEntrance:
    "Should I go and talk to Guards?"
    menu:
        "Go to the entrance and talk to Guards.":
            "Dialogue goes here."
            jump Talked_to_Guard
        "Search for another entrance.":
            "Dialogue goes here."
            jump fail
            
label Talked_to_Guard:
    menu:
        "Talk to the Guard":
            "Dialogue goes here."
            menu:
                "Knock the Guard out":
                    "Dialogue goes here."
                    jump something
                "Find another way.":
                    "Dialogue goes here."
                    jump cleared
        "Knock the Guard out":
            "Dialogue goes here."
            jump fail
        "Find another way":
            "Dialogue goes here."
label fail:
    menu:
        "Die Wachen beseitigen":
            s "Euer schlimmster Alptraum!"
            jump k_o
       "Reden":
           $ gift = "reden_mit_wache"
           "Vielleicht sollte ich erst einmal mit Reden mein Glück versuchen."
           jump wachen_reden
           
label cleared:
    menu:
        "Vorbeischleichen":
            "Also versuchte ich mich an der wache vorbeizuschleichen."
            if gift == "reden_mit_wache":
                jump erwischt
        "Wache ausschalten":
            "Man konnte ja nie wissen, besser ich schaltete diese Wache aus."
            jump hof_des_schlosses

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: If command combined with jump

#6 Post by DragoonHP » Tue Oct 11, 2011 1:21 pm

Thanks for correcting the code Camille... ^.^

User avatar
Der Tor
Miko-Class Veteran
Posts: 504
Joined: Sun Jul 15, 2007 9:03 pm
Completed: Der Totengräber, There is always a Choice
Projects: Ultimate Yandere Simulator, The Comic Strip "Nami Otaku", Koenchu (German version)
Location: Deutschland
Contact:

Re: If command combined with jump

#7 Post by Der Tor » Tue Oct 11, 2011 1:33 pm

I am smelling a German game :D
I have a wiki for German language Visual Novels (as you can see in my signature).
It would be great if you could add it to the wiki once it's finished and it would definitely increase the amount of your readers (at least the amount of readers who can actually understand what you wrote :lol: )
My Itch page:
https://emmanuel-goldstein.itch.io

Besucht mein deutsches Visual Novel Wiki:
http://www.visual-novel.de

SiriWesen
Newbie
Posts: 7
Joined: Tue Oct 11, 2011 6:44 am
Location: Germany
Contact:

Re: If command combined with jump

#8 Post by SiriWesen » Tue Oct 11, 2011 2:48 pm

DragoonHP wrote:It does not matter, it should work on any Ren'Py version... it's one of the most basic feature of Ren'Py...

Can you tell me what was wrong with it?
Ah okay. Glad it's not my lame notebook and stuff this time...

Actually, I'm still not sure if you understood what I was planning to do. After reading the corrected version of your suggestion I think it's not quite that, what I want.

What I wanted is this.

way 1 way 2
talking to the guard(front gate) <-> find another entrance
/
find another entrance
\ /
sneak in
/ \
get detected succes (you haven't talked to the guard)
(you talked to the guard)

So basically, if you have been talking to the guard at the frontgate you fail at sneaking and are forced to fight against the patroling guard. If you decided to sneak inside the castle in the first place and didn't even try the front door you will success in trying to get inside without being seen.

So yeah, that's the short way. How I wanted it.. but yeah, for some reason it didn't work out and I think I don't have the time for worrying about stuff like that...
(there's a deadline for me, for when the game has to be finished... so I maybe should finish writing the simple jump / menu style and THEN adding stuff... :/ )


@Der Tor
Well I'm not sure if I want to publish the result.
you see, this was just planned as some piece of crap for my arts lesson. This practical work is very important for me.
Actually noone ever said, that we have to programme a visual novel or sth like that. (it's far more abstract and boring, than this project may sound). But now that I got started on it, it turns out to be fun the way I do it. Because I do what I want and didn't ask my teacher for allowance. She has to accept it the way it is.
So, if I am satisfied with my project, I will publish it. If not, i won't. I don't want to insult German writers and programmers with my work. xD'

Post Reply

Who is online

Users browsing this forum: No registered users