Help with counter

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
Lilly
Newbie
Posts: 4
Joined: Sun Aug 26, 2018 6:52 pm
Contact:

Help with counter

#1 Post by Lilly »

Hi again, I wasn't sure whether to make a new topic or not, sorry If this should be a followup in my previous post instead ( viewtopic.php?t=54456 )
but this is a new test so I guess its ok. I'm sorry if not!

Anyway, this time I am having trouble with executing a counter. Ren'Py finds no issues with the code and runs the game normally but despite this, the counter conditional is still not executed.

It's just another simple test. You ask Eileen a question. She answers once, then remembers that you have already asked her and her next answer is annoyed, then after you have asked her a set amount of times (5 times) she tells you shes sick of it and the game ends.

Here's my code, thanks!:

Code: Select all

define e = Character("Eileen")

default asked = False

default disney_seen = False

default disney_count = 0




label start:

scene bg room

show eileen happy

if disney_seen:
    e "Hi! Wanna ask a... Wait a sec!"
    e "I already told you my favorite movie is Disney! Why do you wanna do this again?..."
    e "What? You said you wanna do this again?"

elif disney_count > 0 and disney_count >=5:

    e "OKAY I'm sick of you asking the same thing over and over. {w}BYE!"
    return

elif disney_count >0 and disney_count <5:

    menu:

        "Yep!":
            e "Jeez... Ok..."
            jump question

        "Nope.":
         e "Me neither! Bye!"
         return

else:

    e "Hi! Wanna ask me a question?"


menu:

    "Yes.":

        if asked:
            e "You've already asked me!"
            e "Do you want to keep asking anyway?"
            menu:
                "Yes, I want to ask again.":
                    e "Sure!"
                    jump question
                "No, bye.":
                    e "Ok, bye!"
                    return

        else:
            e "Ask me!"
            $ asked = True
            jump question




label question:

    if disney_seen:

        e "There you go again, asking me the question you already know the answer to..."


        menu:

            "What movies do you like?":
                e "Creep!"
                jump movies

    else:

        menu:

            "What movies do you like?":
                jump movies



label movies:

    if disney_seen:
        $ disney_count += 1
        e "I said Disney!"
        jump start



    else:

        "Disney!"
        $ disney_seen = True
        jump start




    return

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Help with counter

#2 Post by Per K Grok »

Lilly wrote: Sun Mar 24, 2019 11:27 pm Hi again, I wasn't sure whether to make a new topic or not, sorry If this should be a followup in my previous post instead ( viewtopic.php?t=54456 )
but this is a new test so I guess its ok. I'm sorry if not!

Anyway, this time I am having trouble with executing a counter. Ren'Py finds no issues with the code and runs the game normally but despite this, the counter conditional is still not executed.

It's just another simple test. You ask Eileen a question. She answers once, then remembers that you have already asked her and her next answer is annoyed, then after you have asked her a set amount of times (5 times) she tells you shes sick of it and the game ends.

Here's my code, thanks!:

Code: Select all

define e = Character("Eileen")

default asked = False

default disney_seen = False

default disney_count = 0
                                                     ### a screen that shows the value of certain variables is not necessary 
                                                     ###but can be nice to have when checking a code
                                                     ### you could make a screen like this
                                                     ### screen disneyC():
    						     ###    text str(disney_count) 



label start:                             #### everything under start needs to be indented one increment more
						###  show screen disneyC
scene bg room

show eileen happy

if disney_seen:
    e "Hi! Wanna ask a... Wait a sec!"
    e "I already told you my favorite movie is Disney! Why do you wanna do this again?..."
    e "What? You said you wanna do this again?"

elif disney_count > 0 and disney_count >=5:                    ### this line will never run since it is an elif statement 
                                                                ### that will not run if disney_seen == True
								### disney_count >0 is not necessary when you also have disney_count >= 5 
								### change to     
								### if disney_count >=5

    e "OKAY I'm sick of you asking the same thing over and over. {w}BYE!"
    return

elif disney_count >0 and disney_count <5:

    menu:

        "Yep!":
            e "Jeez... Ok..."
            jump question

        "Nope.":
         e "Me neither! Bye!"
         return

else:

    e "Hi! Wanna ask me a question?"


menu:

    "Yes.":

        if asked:
            e "You've already asked me!"
            e "Do you want to keep asking anyway?"
            menu:
                "Yes, I want to ask again.":
                    e "Sure!"
                    jump question
                "No, bye.":
                    e "Ok, bye!"
                    return

        else:
            e "Ask me!"
            $ asked = True
            jump question




label question:

    if disney_seen:

        e "There you go again, asking me the question you already know the answer to..."


        menu:

            "What movies do you like?":
                e "Creep!"
                jump movies

    else:

        menu:

            "What movies do you like?":
                jump movies



label movies:

    if disney_seen:
        $ disney_count += 1
        							### show screen disneyC     ### to update screen
        e "I said Disney!"
        jump start



    else:

        "Disney!"
        $ disney_seen = True
        jump start




    return
See comments ### in the code above

Lilly
Newbie
Posts: 4
Joined: Sun Aug 26, 2018 6:52 pm
Contact:

Re: Help with counter

#3 Post by Lilly »

This worked perfectly, thank you so much! I actually thought an elif or else must follow after an if, now I know that another if works.

The screen for the counter helps a lot, thanks again for showing me how to do it! I did give the Screens section of the documentation a read, so I know it would be possible to make a little graphic for my screen counter, even using a picture of my own... for example, if the counter was for mana points a bottle filled with blue liquid, which goes down as the mana points decrease and then up again as they increase. How would you go about making this?

I realise this is kind of a separate question, so if I should put it in a different post, sorry! Let me know and I'll do so ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]