if-statement doesn't do what I want, help please

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
xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

if-statement doesn't do what I want, help please

#1 Post by xMichi »

Edit: problem solved^^

Okay I've tried out what I wrote here before, but I'm coming across a problem. Can someone please help me?

I want to make sure that people will see all the scenes that I made, so I thought of this:

In script file:

Code: Select all

    $ donescenea1 = False
    $ donescenea2 = False
    $ donescenea3 = False
    $ donescenea4 = False
    $ donesceneb1 = False
    $ donesceneb2 = False
    $ donesceneb3 = False
    $ donesceneb4 = False

Code: Select all

label test:
    
    "Day 1"
menu:
    "character a":
        call scenea
    "character b":
        call sceneb

label test2:
    "Day 2"
menu:
    "character a":
        call scenea
    "character b":
        call sceneb
        
label test3:
    "Day 3"
menu:
    "character a":
        call scenea
    "character b":
        call sceneb
        
label test4:        
    "Day 4"
menu:
    "character a":
        call scenea
    "character b":
        call sceneb
    
and then in another file, a scenes file
I put down this:

Code: Select all

label scenea:
     
    if not donescenea1:
        call scenea1

    elif if not donescenea2:
        call scenea2

    elif if not  donescenea3:
        call scenea3

    elif if not  donescenea4:
        call scenea4

    else:  
        call finalscenea
     
     
label sceneb:
    
    if not donesceneb1:
        call sceneb1
 
    elif if not donesceneb2:
        call sceneb2

    elif if not  donesceneb3:
        call sceneb3

    elif if not  donesceneb4:
        call sceneb4

    elif if not  donescenebvijf:
        call scenebvijf

    else:  
        call finalsceneb

and below that:

Code: Select all

label scenea1:
    "a1"
    $ donescenea1 = True
    return

label scenea2:
    "a2"
    $ donescenea2 = True
    return

label scenea3:
    "a3"
    $ donescenea3 = True
    return

label scenea4:
    "a4"
    $ donescenea4 = True
    return

label finalscenea:
    "afinal"
    return
     
 
     
label sceneb1:
    "b1"
    $ donesceneb1 = True
    return

label sceneb2:
    "b2"
    $ donesceneb2 = True
    return

label sceneb3:
    "b3"
    $ donesceneb3 = True
    return

label sceneb4:
    "b4"
    $ donesceneb4 = True
    return

label finalsceneb:
    "bfinal"
    return

The problem is that when I choose

"Character a" at day one,

I'll see "a1" , "b1", "a1"
and then it'll go to day 2.

I'm guessing the fault is in the "return"?
But I have no idea how to solve it, can someone help please?

Edit: Well, looks like this code doesn't work at all anyway, so then I'm wondering what I can do, what kind of code I can use, to get what I want?
I just want to make sure that if you choose character A on day 1, and you view scene1 of character A, that you can still see scene 1 of character B if you choose character B the second day.
And of course I don't want the scene's to repeat.
Last edited by xMichi on Sat May 31, 2014 5:56 pm, edited 1 time in total.

Spiky Caterpillar
Veteran
Posts: 253
Joined: Fri Nov 14, 2008 7:59 pm
Completed: Lots.
Projects: Black Closet
Organization: Slipshod
Location: Behind you.
Contact:

Re: if-statement doesn't do what I want, help please

#2 Post by Spiky Caterpillar »

The problem is that you don't have return statements after the scenea and sceneb blocks. 'return' jumps back to the line immediately after the last 'call' and keeps going from there. Since there's no return before 'label sceneb', it goes into the label sceneb block, calls sceneb1, and keeps going. There's no return before 'label scenea1:', so it runs that as well - then when it finally gets to scenea1's return it jumps back.
Nom nom nom nom nom LEAVES.

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: if-statement doesn't do what I want, help please

#3 Post by xMichi »

Omg. Indeed. Why did I not think of this. Thank you so much T^T now it works... you really saved me. Thank you :3

Post Reply

Who is online

Users browsing this forum: NeonNights