Page 1 of 1

help please! :_:/(User Choices)

Posted: Sun Mar 04, 2012 11:17 am
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?

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

Posted: Sun Mar 04, 2012 11:38 am
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.

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

Posted: Sun Mar 04, 2012 12:18 pm
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!!

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

Posted: Sun Mar 04, 2012 1:31 pm
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

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

Posted: Sun Mar 04, 2012 3:08 pm
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.

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

Posted: Mon Mar 05, 2012 12:26 pm
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!

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

Posted: Mon Mar 05, 2012 1:51 pm
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.