help please! :_:/(User Choices)

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
clua
Miko-Class Veteran
Posts: 537
Joined: Sat Dec 12, 2009 1:38 pm
Completed: Stormy Night /The Knife of the Traitor/Charlatans
Projects: The Hurtful Wall /_Salomon/Infurubia
Tumblr: notttt-che
itch: chegovia
Location: In a jar with pirañas
Contact:

help please! :_:/(User Choices)

#1 Post by clua »

I have this problem:

When my game starts, I give multiple choice options for the player to go(three places)

Code: Select all

menu:

        "Go to the Basement":
        
            jump ba
            
        "Go to the Kitchen":
        
            jump ki
            
        "Go to the Watchtower":
        
            jump wt
and what I want to do is call another scene if I visit the same place for the second time(Since I dont know which place will the player choose first)

how can I do it? or is there a place on the cookbook where it explains me that?
♦WIP♦
Infurubia
The hurtful wall
_Salomon

♦COMPLETE♦
+The Knife of the Traitor(Nanoreno 2012)
+Charlatans(Nanoreno 2015)

Dev tumblr
EVN Store

SpoilerDuck
Newbie
Posts: 17
Joined: Thu Apr 07, 2011 10:27 am
Contact:

Re: help please! :_:/(User Choices)

#2 Post by SpoilerDuck »

The simplest way would be to have a variable check at the beginning of each scene. So say you choose "kitchen", you have:

Code: Select all

if has_visited_kitchen == False:
    #Events for the first time visit
    $ has_visited_kitchen = True
    jump next_label
elif has_visited_kitche == True:
    #Events for the second visit
    jump next_label
So basically, upon the first visit to the kitchen the variable has_visited_kitchen is set to True, which means on subsequent visits the game will know the player has been there and can run a separate block of code.

User avatar
clua
Miko-Class Veteran
Posts: 537
Joined: Sat Dec 12, 2009 1:38 pm
Completed: Stormy Night /The Knife of the Traitor/Charlatans
Projects: The Hurtful Wall /_Salomon/Infurubia
Tumblr: notttt-che
itch: chegovia
Location: In a jar with pirañas
Contact:

Re: help please! :_:/(User Choices)

#3 Post by clua »

SpoilerDuck wrote:The simplest way would be to have a variable check at the beginning of each scene. So say you choose "kitchen", you have:

Code: Select all

if has_visited_kitchen == False:
    #Events for the first time visit
    $ has_visited_kitchen = True
    jump next_label
elif has_visited_kitche == True:
    #Events for the second visit
    jump next_label
So basically, upon the first visit to the kitchen the variable has_visited_kitchen is set to True, which means on subsequent visits the game will know the player has been there and can run a separate block of code.
D:!! I think It worked! I will report this in a while after I try the other codes too XD

Thank you so much!!
♦WIP♦
Infurubia
The hurtful wall
_Salomon

♦COMPLETE♦
+The Knife of the Traitor(Nanoreno 2012)
+Charlatans(Nanoreno 2015)

Dev tumblr
EVN Store

User avatar
clua
Miko-Class Veteran
Posts: 537
Joined: Sat Dec 12, 2009 1:38 pm
Completed: Stormy Night /The Knife of the Traitor/Charlatans
Projects: The Hurtful Wall /_Salomon/Infurubia
Tumblr: notttt-che
itch: chegovia
Location: In a jar with pirañas
Contact:

Re: help please! :_:/(User Choices)

#4 Post by clua »

Sorry Im a complete noob to this ;_;---It doesnt work what I did was the following:
the label "cho2" is the menu that appears after you make your first visit in any of the 3 locations

Code: Select all

label cho2:
    c"Well, Shall we go now?"
    o"*nods*"
    play music "two_warriors.mp3"
    menu:

          "Go to the Basement":
           jump ba
            
          "Go to the Kitchen": 
           jump ki
        
          "Go to the Watchtower":
           jump wt
            
label ki:
    if has_visited_kitchen == False:
    #Events for the first time visit
    $ has_visited_kitchen = True
    jump ki2
elif has_visited_kitchen == True:
    #Events for the second visit
    jump ki2
D: Or this should be on the menu code?...orz
♦WIP♦
Infurubia
The hurtful wall
_Salomon

♦COMPLETE♦
+The Knife of the Traitor(Nanoreno 2012)
+Charlatans(Nanoreno 2015)

Dev tumblr
EVN Store

SpoilerDuck
Newbie
Posts: 17
Joined: Thu Apr 07, 2011 10:27 am
Contact:

Re: help please! :_:/(User Choices)

#5 Post by SpoilerDuck »

Did you declare the variable has_visited_kitchen as 'false' at the beginning of your game? You'd want to place it in your Start label, so:

Code: Select all

label start:
    $ has_visited_kitchen = False
    jump cho2
Replace cho2 with whatever label you actually want the player to go to first etc.

User avatar
clua
Miko-Class Veteran
Posts: 537
Joined: Sat Dec 12, 2009 1:38 pm
Completed: Stormy Night /The Knife of the Traitor/Charlatans
Projects: The Hurtful Wall /_Salomon/Infurubia
Tumblr: notttt-che
itch: chegovia
Location: In a jar with pirañas
Contact:

Re: help please! :_:/(User Choices)

#6 Post by clua »

SpoilerDuck wrote:Did you declare the variable has_visited_kitchen as 'false' at the beginning of your game? You'd want to place it in your Start label, so:

Code: Select all

label start:
    $ has_visited_kitchen = False
    jump cho2
Replace cho2 with whatever label you actually want the player to go to first etc.
I think..I might be doing something wrong...But Im not sure what it is...
I did declare it at the start of the game(I realized I had to because of this), but when I used the other code before the scene it took me directly to the second scene the first time
when I messed a bit with the code..The game freezed orz
The game code goes like this_

Code: Select all

label start:
    $ has_visited_kitchen = False
    $ has_visited_basement = False
    $ has_visited_watchtower = False
    
    $ corvus = 0
    $ vorges = 0
    $ gervase = 0
    $ lilja = 0
    
    #blablabla goes here
    c"Why dont we explore the tower a little...I think there were some slav- I mean servants inside"
    o"*nods*"
    play music "scale-two_warriors.mp3"
    menu:

        "Go to the Basement":
        
            jump ba
            
        "Go to the Kitchen":
        
            jump ki
          
        "Go to the Watchtower":
        
            jump wt
    
    
#If you jump to any of those labels, they in the end will lead you to cho2 

label cho2:
    c"Well, Shall we go now?"
    o"*nods*"
    play music "scale-two_warriors.mp3"
    menu:

          "Go to the Basement":
           jump ba
            
          "Go to the Kitchen":
           jump ki
        
          "Go to the Watchtower":
           jump wt
            
label ki:
if has_visited_kitchen == False:
         $ has_visited_kitchen = True
         jump ki2
elif has_visited_kitchen == True:
    jump ki2
    stop music fadeout 1.5
    scene black with aaa
    c"Whats the matter with this tower. Each place stinks worst than the other!"
    o"..."
;_;..sorry for asking this much!
♦WIP♦
Infurubia
The hurtful wall
_Salomon

♦COMPLETE♦
+The Knife of the Traitor(Nanoreno 2012)
+Charlatans(Nanoreno 2015)

Dev tumblr
EVN Store

SpoilerDuck
Newbie
Posts: 17
Joined: Thu Apr 07, 2011 10:27 am
Contact:

Re: help please! :_:/(User Choices)

#7 Post by SpoilerDuck »

In both the first and second visit you're sending the player to "ki2". You wouldn't notice a difference because there isn't one.

Also, in your code for has_visited_kitchen == True:

Code: Select all

has_visited_kitchen == True:
    jump ki2
    stop music fadeout 1.5
    scene black with aaa
    c"Whats the matter with this tower. Each place stinks worst than the other!"
    o"..."
Everything after "jump ki2" is going to be ignored, as you've already jumped to a different label.

If you want to do it via separate labels, you want "has_visited_kitchen == False" to send the player to a 'ki1' and "has_visited_kitchen == True" to send the player to ki2. You don't need to send them elsewhere though.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]