Interactive choose-your-path-game problem

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
TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Interactive choose-your-path-game problem

#1 Post by TakeNoSh1t » Mon Dec 13, 2010 12:02 pm

Im new at Ren'Py but have already been able to do a simple game where the player can answer a question and gett two different reactions from the person he/she talks to. The thing is that I want the dialogue to continue based on the players response to what the characters in the game say to him/her.

Example:
Yosh: "Hey thats my sandwich! Give it to me!"
The player can choose between "No way!" and "Come on i have'nt eaten anything today!"
If the player choose "No way" Yosh will say: "I was'nt asking. Give me the sandwich now before you get hurt!"
After that i want the player to be able to pick something to say back to Yosh. Like: "Fine,have your sandwich!" Or "If you want to fight,I'll fight you!"

I want the game to continue like that with different reactions and different things that happend based on what the player chooses to say. The problem is I dont know how to get this to work in the game! I've tried,and this is how it looks but I only get errors all the time
Image

Please help..and forgive my poor english

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Interactive choose-your-path-game problem

#2 Post by Aleema » Mon Dec 13, 2010 12:24 pm

Haha, your indentation is a bit off. Does that work? I don't think that would work. No, it wouldn't. You're making me doubt myself!!

If you copy/paste your code into a [code*] label, I could show you how to format. In general, the "label XXX" line goes on the VERY EDGE of your screen, like with "init:" lines. Everything else is tabbed over once.

To answer your question, in order to remember what choice the user made, you should have a variable that is changed depending on what menu item you made. You then check that variable later with an If statement, and react accordingly.

Code: Select all

    menu:
        "The greatest national pasttime!":
            $ likes_baseball = True
            "Heck yeah!"
        "I hate baseball.":
            $ likes_baseball = False
            "Terrorist!"
            
    if likes_baseball: #same as saying "if likes_baseball == True"
        "Good thing you like baseball."
    else: #likes_baseball is not True, meaning it is False
        "GTFO!"
You can make a variable like "likes_baseball" at any time as you need them. Just make sure there is no way the variable cannot be set, otherwise you will get an error once you check a variable that doesn't exist!

More about remembering choices is here.

TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Re: Interactive choose-your-path-game problem

#3 Post by TakeNoSh1t » Mon Dec 13, 2010 1:03 pm

Hehe the game worked fine with the small indentations, the problems started when I did a second 'menu:' underneath the first 'menu: thingy.
This is what it looks like in code..I pretty much just experimented when I put in the second 'menu:'. I just thought that it was pretty much the only logical thing to do for another 'pick yo response'-interaction thing..heh :oops:

Code: Select all

 scene bg cafeteria Yosh
   Yo "Hey,hey you! Punk!" 
   Y "Uh,me?"
   Yo "Yes you! I was gonna get that last sandwich! Give it to me."
   
menu:

 "No way!":
  jump choice1_noway

 "Come on,I have'nt eaten anything for lunch today!": 
  jump choice1_comeon

label choice1_noway:
$ menu_flag = True
scene bg cafeteria Yosh angry
Yo "I was'nt asking"
Yo "Give it to me now before you get hurt!"
jump choice1_done

    menu:
 
     "You cant hit me,I'm a girl!":
        jump choice2_imagirl

     "I'll face you like the man I am!":
        jump choice2_imaman

    label choice2_imagirl
    $ menu_flag = True
    Yo "I dont care! I'll slap the crap out of you if you dont give me that sanwich this instant!"
    jump choice2_done

    label choice2_imaman
    $ menu_flag = False
    Yo "Suit yourself"
    jump choice2_done
    label choice2_done:

label choice1_comeon:
$ menu_flag = False
Yo "I dont care! Give me the damn sandwich,NOW!"
jump choice1_done
label choice1_done:

User avatar
Chansel
Veteran
Posts: 249
Joined: Sat May 01, 2010 6:11 pm
Projects: School's Out! -- A GxB or GxG VN/Dating Sim
Location: The Netherlands, Noord-Brabant
Contact:

Re: Interactive choose-your-path-game problem

#4 Post by Chansel » Mon Dec 13, 2010 1:10 pm

Code: Select all

If you copy/paste your code into a [code*] label, I could show you how to format. In general, the "label XXX" line goes on the VERY EDGE of your screen, like with "init:" lines. Everything else is tabbed over once.
You don’t HAVE to tap everything once after the “label XX:”, but python does want you to do it for some reason O.o I know it automatically ‘tabs’ once if I press enter after a label, but I always delete that tab and continue writing everything without that one tab in front. I find that if I tab all my labels, there’s going to be too many blocks @.@ And let me assure you, it works. Might not be the official way, I’m not sure. But it all works ;)
Image ~ A GxB or GxG Visual Novel/Dating Sim

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Interactive choose-your-path-game problem

#5 Post by Aleema » Mon Dec 13, 2010 1:17 pm

THAT'S CRAZY. Why does that work? Stop it! Bad! xD
Okay, I stand corrected. Have fun trying to distinguish labels from each other. =P

First indents aside, indentation is important and how the language recognizes what belongs to what.

You can make menus inside of menus, you just have to make sure the tabbing is right:

Code: Select all

menu:

     "You cant hit me,I'm a girl!":
        menu:
            "You cant hit me,I'm a girl!":
                jump choice2_imagirl
            "I'll face you like the man I am!":
                jump choice2_imaman

     "I'll face you like the man I am!":
        jump choice2_imaman

TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Re: Interactive choose-your-path-game problem

#6 Post by TakeNoSh1t » Mon Dec 13, 2010 1:30 pm

I get this error message when i try to run the game...

Code: Select all

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


On line 56 of C:\Users\Jonny\Ren'Py\My high school life/game/script.rpy: jump statement does not expect a block. Please check the indentation of the line after this one.
jump choice1_done
    ^
Thats the only error I get now but I dont know how to fix it :/

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Interactive choose-your-path-game problem

#7 Post by Aleema » Mon Dec 13, 2010 1:35 pm

Post exactly what you have ... (this is an indentation error)

TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Re: Interactive choose-your-path-game problem

#8 Post by TakeNoSh1t » Mon Dec 13, 2010 1:38 pm

This is the entire code for the game (not so long yet, I've only made the beginning of the game :P)

Code: Select all

# You can place the script of your game in this file.

init:
    # Declare images below this line, using the image statement.
    image bg corridor = "the_corridor.jpg"
    image bg cafeteria = "cafeteria_trizany_stock.jpg"
    image bg cafeteria staff = "cafeteria_zoom2.jpg"
    image bg cafeteria close = "cafeteria_zoom.jpg"
    image bg cafeteria Yosh = "cafeteria_zoom3.jpg"
    image bg cafeteria Yosh angry = "cafeteria_zoom4.jpg"
    # Declare characters used by this game.
    $ Y = Character('You', color="#c8ffc8")
    $ CS = Character('Cafeteria Staff', color="#ccccff")
    $ Yo = Character('Yosh', color="#660000")
   

# The game starts here.
label start:
   play music "guitar_NPC.mp3"
   scene bg corridor

   Y "Why did Mr Murphy have to give me detention? I almost missed lunch! Im so hungry I could eat a horse!"

   Y "Oh, but Im lucky if there's anything left at this hour. Gotta hurry to the Cafeteria!"
  
   scene bg cafeteria
   
   Y "Some students are still here, so hopefully something's left to eat!"

   scene bg cafeteria staff
   CS "Hi there! You seem to be in a hurry. I cant really blame you, we'll be closing soon. You're just in time!"
   Y "Hi. Do you have anything left, or am I too late?"
   CS "Well, you're quite a lucky fellow! We have this last sandwich left for today."
   Y "Excellent! Thank you!"

   scene bg cafeteria close  
   Y "Oboy finally something to eat! And i dont have to worry about finding a place to sit down, haha!"
   scene bg cafeteria Yosh
   Yo "Hey,hey you! Punk!" 
   Y "Uh,me?"
   Yo "Yes you! I was gonna get that last sandwich! Give it to me."
   
menu:

     "No way!":
        jump choice1_noway

     "Come on,I have'nt eaten anything for lunch today!": 
        jump choice1_comeon

label choice1_noway:
$ menu_flag = True
scene bg cafeteria Yosh angry
Yo "I was'nt asking"
Yo "Give it to me now before you get hurt!"
jump choice1_done

          menu:
 
             "You cant hit me,I'm a girl!":
                 jump choice2_imagirl

             "I'll face you like the man I am!":
                 jump choice2_imaman

          label choice2_imagirl
          $ menu_flag = True
          Yo "I dont care! I'll slap the crap out of you if you dont give me that sanwich this instant!"
          jump choice2_done

          label choice2_imaman
          $ menu_flag = False
          Yo "Suit yourself"
          jump choice2_done
          label choice2_done:

label choice1_comeon:
$ menu_flag = False
Yo "I dont care! Give me the damn sandwich,NOW!"
jump choice1_done
label choice1_done:

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Interactive choose-your-path-game problem

#9 Post by Aleema » Mon Dec 13, 2010 1:45 pm

Okay, first problem: you have a jump right before your menu. If you jump away from that label, you will NEVER see anything under it. You've moved away. What is that jump to choice1_done supposed to do?

The error (is probably ) because you're starting your menu waaay over to the right. It should be on the same indentation as the previous jump statement. Indentation is not just for cosmetics. (Normally) it can't be just anywhere you want. It's pretty uniform. Meaning, it should look like this:

Code: Select all

label choice1_noway:
$ menu_flag = True
scene bg cafeteria Yosh angry
Yo "I was'nt asking"
Yo "Give it to me now before you get hurt!"
jump choice1_done

menu:

    "You cant hit me,I'm a girl!":
        jump choice2_imagirl
    
    "I'll face you like the man I am!":
        jump choice2_imaman
... Right?

TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Re: Interactive choose-your-path-game problem

#10 Post by TakeNoSh1t » Mon Dec 13, 2010 1:55 pm

what about the

Code: Select all

label choice2_imagirl
$ menu_flag = True
Yo "I dont care! I'll slap the crap out of you if you dont give me that sanwich this instant!"
jump choice2_done

label choice2_imaman
$ menu_flag = False
Yo "Suit yourself"
 jump choice2_done
label choice2_done:

label choice1_comeon:
$ menu_flag = False
Yo "I dont care! Give me the damn sandwich,NOW!"
jump choice1_done
label choice1_done:

That comes right after? the label-thingy have to be on the same 'line' as the menu,and when I do that I get many more errors..ugh T__T

Code: Select all

menu:

     "No way!":
        jump choice1_noway

     "Come on,I have'nt eaten anything for lunch today!": 
        jump choice1_comeon

label choice1_noway:
$ menu_flag = True
scene bg cafeteria Yosh angry
Yo "I was'nt asking"
Yo "Give it to me now before you get hurt!"
jump choice1_done

menu:
 
             "You cant hit me,I'm a girl!":
                 jump choice2_imagirl

             "I'll face you like the man I am!":
                 jump choice2_imaman

label choice2_imagirl
$ menu_flag = True
Yo "I dont care! I'll slap the crap out of you if you dont give me that sanwich this instant!"
jump choice2_done

label choice2_imaman
$ menu_flag = False
Yo "Suit yourself"
 jump choice2_done
label choice2_done:

label choice1_comeon:
$ menu_flag = False
Yo "I dont care! Give me the damn sandwich,NOW!"
jump choice1_done
label choice1_done:

Result in error:

Code: Select all

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


On line 66 of C:\Users\Jonny\Ren'Py\My high school life/game/script.rpy: expected ':' not found.
label choice2_imagirl
                     ^

On line 71 of C:\Users\Jonny\Ren'Py\My high school life/game/script.rpy: expected ':' not found.
label choice2_imaman
                    ^

On line 73 of C:\Users\Jonny\Ren'Py\My high school life/game/script.rpy: say statement does not expect a block. Please check the indentation of the line after this one.
Yo "Suit yourself"
                  ^
Sorry if im being irritating but I seriously dont understand this

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Interactive choose-your-path-game problem

#11 Post by Aleema » Mon Dec 13, 2010 1:59 pm

Read the error: You need a colon after those lines. Remember, labels end with a colon, right?
label choice2_imagirl -> label choice2_imagirl:
label choice2_imaman -> label choice2_imaman:

The other error is because you can't have a blank label. You have this label "label choice2_done:" but nothing is under it. You just make a new label. Either put a blank line under that label, or remove it.

TakeNoSh1t
Newbie
Posts: 13
Joined: Mon Dec 13, 2010 11:35 am
Contact:

Re: Interactive choose-your-path-game problem

#12 Post by TakeNoSh1t » Mon Dec 13, 2010 2:13 pm

Oooh..cool it works now! Thanks for the help ^____^

Post Reply

Who is online

Users browsing this forum: _ticlock_