Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email pytom@bishoujo.us.
It is currently Tue Oct 21, 2014 12:40 pm

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Mon Apr 19, 2010 3:22 pm 
Newbie
User avatar

Joined: Sat Apr 17, 2010 8:04 pm
Posts: 20
Projects: Untitled VN project: Still in its beginnings, but hopeful. :D
Hi there!

I'm still having the problem where the latest version of Renpy doesn't wants to edit any scripts on my PC (it can't select any editor in the options), so I'm using the 6.3.3 version I had saved a while ago, but hopefully this shouldn't affect what I needed to ask about:

I looked through the FAQ and forum etc. but couldn't find an answer for it: Is there a way to make a trivia/quiz little test in renpy? I figure there must be an obvious way that I'm just not seeing because I'm a total noob when it comes to coding, sadly. ^^;;

The idea is that I want to have the love interest character to ask a series of questions to the player-controlled main character, and if they get the answers right, they can progress to getting closer to that character.
(It would be questions about the character, on things which we'd have seen before in the game etc., kind of to show that the main character is interested and remembers the things about the character they're trying to approach.)

I've been trying to figure out how to do it, but I'm really not sure and couldn't find anything on quizzes. ^^;

If someone could kindly write an example of how such a trivia/quiz code could work with 2 or 3 fake questions, it would be absolutely awesome! :D :D

As of now I'm not sure yet whether you would get a bad end to the game right away if you fail the quiz (in case it's not possible to have a quiz code work to go back into the main path and try again later), or if you just get the love interest character to be disappointed but try again later maybe. It will depend on how it works. XD

I've seen ren'ai games before where you have to repeat dates over and over until you answer all they want right or until you build up enough "love/liking points" from them or something like that, but I have no idea how to do it, and am afraid it might make the game a bit more complicated. ^^; So I'll probably just stick to the trivia/quiz thingie. ^^

Thank you so much in advance, to anyone who can help. :D :D

_________________
Night ❤ Hall
http://www.sagakure.net/
Image

(My Vampire Knight fan site.)


Top
 Profile Send private message  
 
PostPosted: Mon Apr 19, 2010 5:53 pm 
Lemma-Class Veteran
User avatar

Joined: Fri May 23, 2008 2:11 pm
Posts: 2563
Location: USA
Organization: Happy Backwards
Well, I figured you'd make use of the menu system, and use a variable to keep track of how many questions they got right. At the end, you just check the variable (by whatever standard you want them to win), and then use an If clause to split the story.
Code:
label quiz:
    b "Who would cross the Bridge of Death must answer me these questions three, ere the other side he see."
    l "Ask me the questions, bridgekeeper. I am not afraid."
   
    #Initialize score
    $ quiz_score = 0
   
    # 1st Question
    b "What... is your name?"
    menu:
        "Sir Lancelot of Camelot":
            l "My name is Sir Lancelot of Camelot."
            $ quiz_score += 1
        "Sir Galahad of Camelot.":
            l "My name is Sir Galahad of Camelot"
       
    # 2nd Question
    b "What... is your favourite colour?"
    menu:
        "Blue":
            l "Blue."
            $ quiz_score += 1
        "Yellow":
            "Blue. No, yel..."
           
    # 3rd Question
    b "What... is the air-speed velocity of an unladen swallow?"
    menu:
        "I don't know":
            l "I don't know that!"
        "African or European?":
            l "What do you mean? An African or European swallow?"
            $ quiz_score += 1
           
    # Check the quiz score
    if quiz_score == 3:
        # Win
        b "Go on. Off you go."
        l "Oh, thank you. Thank you very much."
        # Did he win? Yes.
        $ win = True
    else:
        # Lose
        l "Auuuuuuuugh!"
        # Did he win? No.
        $ win = False


And then later, you can check on the variable "win" to see if the character passed the test.

And don't worry, most games do involve a point system, so unless you're uncomfortable with it -- let loose!

_________________
I can be reached for game support through the Happy Backwards forums or email.
How to Customize the Textbox | How to Customize Game Menus | Icon art by Mocha07734


Top
 Profile Send private message  
 
PostPosted: Mon Apr 19, 2010 6:52 pm 
Newbie
User avatar

Joined: Sat Apr 17, 2010 8:04 pm
Posts: 20
Projects: Untitled VN project: Still in its beginnings, but hopeful. :D
That reply is made of SO MUCH WIN! :D :D :D *huge Monty Python fan here*

I think I understand it now. :D I'll come back if I get stuck somewhere when I put it into use, but I think that it should go fine despite my noob-ness, it's really well explained. :D
Thank you SO much, it's very helpful! :D :D :D

_________________
Night ❤ Hall
http://www.sagakure.net/
Image

(My Vampire Knight fan site.)


Top
 Profile Send private message  
 
PostPosted: Fri Apr 23, 2010 12:22 am 
Newbie
User avatar

Joined: Sat Apr 17, 2010 8:04 pm
Posts: 20
Projects: Untitled VN project: Still in its beginnings, but hopeful. :D
Hi again! :D

I've gotten to the part of the game where I use the code, and it's working wonderfully! :D :D


I modified it a tiny bit so that I could have more quizzes leading to different sub-branches of the story, and so far it's working, but my code-writing skills are to programming pretty much what a monkey throwing fruit in the direction of a target is to marksmanship, so I wanted to make sure the little chunk of code I came up with won't cause chaos later down the road. ^^;;

I kept it the original way, just changing it from quiz to quiz1, and then changing the ending like this:
Code:
    # Check the quiz score
    if quiz1_score == 3:
        # Win
        b "Go on. Off you go."
        l "Oh, thank you. Thank you very much."
        # Did he win? Yes.
        $ quiz1_win = True
        $ quiz1_lose = False
       
    else:
        # Lose
        l "Auuuuuuuugh!"
        # Did he win? No.
        $ quiz1_win = False
        $ quiz1_lose = True

But I'm not sure if I should have the two things (quiz1_win and quiz1_lose) in each for win and lose. Is it the right way to do it so that I can use a "quiz1_win = True" or False, and so on later? Or should I not have win and lose but just use "quiz1_win" true or false? Would it change anything?
I wanted to check with you, because sometimes things seem logical for someone who doesn't speaks the language well, and it turns out they're not logical at all... and since programming is very much like a language, I wasn't sure if I'd done it right. ^^;
And right about now I'm getting the feeling that what I added was dumb and that all I needed was to use win = true or false instead of adding the lose option. XD;;; I'm not sure. ^^;


After this part, the characters talk and all sorts of things happen, and later down the road this comes up:
Code:
   
    if quiz1_win:
        jump happylove
       
    if quiz1_lose:
        jump breakup
   
Which is working so far, so I'm guessing it's okay to keep it this way, or is there a better way to put it? (In case this way might cause any problems.)

This is just my basic thing for now as I progress little bit by little bit. Once I add the extra subplots and things, I'd like to be able to not do just a jump from two options like that, but also to use the results of the previous quizzes to affect the things characters say and do, the way it was with the example in The_Question about "$ bl_game = True" being called later on with "if bl_game:" to change what the guy is talking about.


I'm trying to make them have a conversation in which the results of the quizzes come up, and then have a new option pop up based on that.
I wrote a code thingie for it, but it's not working, so I was wondering if what I'm doing is a total misuse of the menu, or if I just made a mistake somewhere that can be fixed? ^^;
Code:
    k "talk talk talk"
    z "talk."
   
    if quiz1_lose:
        k "I always knew you never truly cared for so-and-so (or whatever like that XD)."
        z "You bet I don't!"
                 
    if quiz1_win:
        k "I always knew you cared for so-and-so (or whatever like that XD)."
        z "I... I tried to hide something from you..."
        k "You did...?"     
        menu:
            "Yeah, you're actually the one I love!!"
                jump happylove
            "Yeah, I hid that I actually hate you!!"
                jump breakup
I'm getting errors about the presence of jump there, but I'm not sure if there's another way to do this? ^^;

This is of course not the final text, btw. XD I'm hoping it will sound less lame by the time I get to the actual dialogue. *lol*


And also, is there a way to use "if quiz1_win" and "if quiz2_win" in the same line? To get to something the character wouldn't get to unless he wins both quizzes? Because in the example I wrote it's using the results independently, while it would be good if the character could give a different response if the player got everything right in the different quizzes. :D
Or would I have to use the point system for that? (I'm looking into that and it seems very interesting too, but maybe I'll combine both the quizzes with win or lose results, and the points for something else.)

Sorry for so many questions, but while I'm asking about the quizzes, if a character jumps back to a past quizz again, and retake it if they failed the first time, will ren'py remember their victory gotten the second time, or the initial loss? So, will they be able to retake quizzes they failed, or will they be screwed and have to have a bad end and redo the game to get the right path?


I'm still a bit tangled with how I'll make it all work together, but I'm learning along the way and it's also being very fun. :D
So right now I'm very happy and hopeful about the game and the story coming alive. :D

Thank you so much for your patience and for all the help, your posts are very helpful! :D :D :D (I'm a bit of a forum stalker collecting code from many people in various other threads whenever I find something that helps what I have in mind for my game, as you must have noticed from my other post. XD)

_________________
Night ❤ Hall
http://www.sagakure.net/
Image

(My Vampire Knight fan site.)


Top
 Profile Send private message  
 
PostPosted: Fri Apr 23, 2010 1:42 am 
Lemma-Class Veteran
User avatar

Joined: Fri May 23, 2008 2:11 pm
Posts: 2563
Location: USA
Organization: Happy Backwards
No problem! Asking questions is what this forum is about. I just try to do my part in relieving PyTom's stress by helping out. >_>
Sagakure wrote:
But I'm not sure if I should have the two things (quiz1_win and quiz1_lose) in each for win and lose. Is it the right way to do it so that I can use a "quiz1_win = True" or False, and so on later? Or should I not have win and lose but just use "quiz1_win" true or false? Would it change anything?
I wanted to check with you, because sometimes things seem logical for someone who doesn't speaks the language well, and it turns out they're not logical at all... and since programming is very much like a language, I wasn't sure if I'd done it right. ^^;
And right about now I'm getting the feeling that what I added was dumb and that all I needed was to use win = true or false instead of adding the lose option. XD;;; I'm not sure. ^^;

Right now, you don't need to have two separate variables, one for winning and one for losing. You can check on the one variable to see if they won or lost. Meaning, you would check to see if it was True (won) or False (lost). Checking this is simpler than you'd think.
Code:
    if quiz1_win:
        jump happylove
       
    if not quiz1_win:
        jump breakup

As you can see, I just added the word "not". You can also do the same thing with different wording (if it makes you feel more comfortable):
Code:
    if quiz1_win == True:
        jump happylove
       
    if quiz1_win == False:
        jump breakup


Also, for reference sake, you can also phrase the If statement to not even check if it's false:
Code:
    if quiz1_win:
        jump happylove
    else:
        jump breakup

The "else" would mean any other variable that is not "True" (aka "False") will result in jumping to "breakup". Using If/Else statements are so crucial to branching the story, so I'd thought I'd share. ^^;

But yes, it's perfectly fine to code it the way you did. There aren't any code police that are going to arrest you. Always code the way you're comfortable! You'll just save some precious time by only having to check one variable. :)

Sagakure wrote:
I'm getting errors about the presence of jump there, but I'm not sure if there's another way to do this? ^^;

Haha, that's just a simple mistake. You forgot to put colons (:) after the menu choices. It should work once you put those in:
Code:
menu:
            "Yeah, you're actually the one I love!!":
                jump happylove
            "Yeah, I hid that I actually hate you!!":
                jump breakup


Quote:
And also, is there a way to use "if quiz1_win" and "if quiz2_win" in the same line? To get to something the character wouldn't get to unless he wins both quizzes? Because in the example I wrote it's using the results independently, while it would be good if the character could give a different response if the player got everything right in the different quizzes.

Yes! Let me show you:
Code:
        if quiz1_win and quiz2_win:
            jump doubleawesome
        elif quiz1_win:
            jump onescene
        elif quiz2_win:
            jump twoscene
        else:
            jump yousuck

I went through every possible scenario. You can use the words "and", "or" and "not" to determine a variable. So, if I wanted to show only one particular scene if you got either quiz1 or quiz2 correct, then I would say "if quiz1_win or quiz2_win".

I've learned that "elif" is your friend! It means "else if", so you don't have to keep making If statements over and over inside of each other. Save a lot of space and indentations if you're checking a lot of variables. :)

Quote:
Sorry for so many questions, but while I'm asking about the quizzes, if a character jumps back to a past quizz again, and retake it if they failed the first time, will ren'py remember their victory gotten the second time, or the initial loss? So, will they be able to retake quizzes they failed, or will they be screwed and have to have a bad end and redo the game to get the right path?

Ren'Py will remember it. The variable should change, meaning Ren'Py will update the win and when you check it again, it should correctly read that they won it.

And don't be embarrassed to ask questions. Everyone starting out is just as clueless as you are right now. :D Thanks for the compliment, too!

_________________
I can be reached for game support through the Happy Backwards forums or email.
How to Customize the Textbox | How to Customize Game Menus | Icon art by Mocha07734


Top
 Profile Send private message  
 
PostPosted: Tue Jan 18, 2011 8:28 pm 
Newbie
User avatar

Joined: Tue Jan 18, 2011 4:28 pm
Posts: 9
I'm new here, and I realize that this thread is kind of old, but if anyone reads this, would there be any way to make it so in a quiz/trivia like minigame, the player can only get three wrong before losing?


Top
 Profile Send private message  
 
PostPosted: Tue Jan 18, 2011 8:41 pm 
Miko-Class Veteran
User avatar

Joined: Tue Jul 24, 2007 12:58 pm
Posts: 555
Konorai Kairo wrote:
I'm new here, and I realize that this thread is kind of old, but if anyone reads this, would there be any way to make it so in a quiz/trivia like minigame, the player can only get three wrong before losing?


Certainly. You'd probably want to keep a running tally of the score, and then check if it's too low/high/whatever before each question... Something like:

Code:

$ mistakes = 0
$ score = 0

a "Question 1."
menu:
    "True.":
        "It was true."
        $ score += 1
    "False.":
        "Bad luck, it was true."
        $ mistakes += 1
if mistakes > 2:
    jump youlose

a "Question 2."
menu:
    "True.":
        "It was true."
        $ score += 1
    "False.":
        "Bad luck, it was true."
        $ mistakes += 1
if mistakes > 2:
    jump youlose

a "Question 3."
menu:
    "True.":
        "It was true."
        $ score += 1
    "False.":
        "Bad luck, it was true."
        $ mistakes += 1
if mistakes > 2:
    jump youlose

a "Question 4."
menu:
    "True.":
        "It was true."
        $ score += 1
    "False.":
        "Bad luck, it was true."
        $ mistakes += 1
if mistakes > 2:
    jump youlose

a "Question 5."
menu:
    "True.":
        "It was true."
        $ score += 1
    "False.":
        "Bad luck, it was true."
        $ mistakes += 1
if mistakes > 2:
    jump youlose


Of course, you could tidy that up... You wouldn't need to check before the first two questions as it would be impossible to have three wrong at that stage.


Top
 Profile Send private message  
 
PostPosted: Tue Jan 18, 2011 8:50 pm 
Newbie
User avatar

Joined: Tue Jan 18, 2011 4:28 pm
Posts: 9
Kya~ Thanks so much~

It makes so much more sense if you do the tally thing. :3

<-- juvenile personality~

^--------obession with the squiggly


Top
 Profile Send private message  
 
PostPosted: Sat Jan 22, 2011 4:12 pm 
Newbie
User avatar

Joined: Tue Jan 18, 2011 4:28 pm
Posts: 9
O_o. Oh, and (sorry for the double post) is there a way to make it so you can only get to the youlose label if you fail the quiz/test? Like, you can only get to it under certain conditions (such as failing the quiz or doing something else wrong.)


Top
 Profile Send private message  
 
PostPosted: Sat Jan 22, 2011 9:04 pm 
Lemma-Class Veteran
User avatar

Joined: Fri May 23, 2008 2:11 pm
Posts: 2563
Location: USA
Organization: Happy Backwards
That's what's already happening in the script Showsni posted. Say exactly what you want to happen, and we can help you out.

In general, though, please read up on the If statement. It's a magical line of code that makes sure things only happen "If ..." and then you list the conditionals. In Showsni's script, it was "if mistakes > 2" (If you had more than 2 mistakes). If you wanted it to be "If you failed the quiz" you would have to personally know how many wrong answers were required to "fail" the quiz and change the 2 accordingly. As it is now, you fail after 2 wrong answers.

If what you mean is to REMEMBER if you failed, you need to make a new variable than can be True or False, as my example above did.

_________________
I can be reached for game support through the Happy Backwards forums or email.
How to Customize the Textbox | How to Customize Game Menus | Icon art by Mocha07734


Top
 Profile Send private message  
 
PostPosted: Fri Jan 11, 2013 11:19 am 
Newbie

Joined: Tue Jun 19, 2012 2:04 am
Posts: 3
Projects: kanji
sorry, how to show the score in the text?

a "you're score : 3" and 3 is the score variable .


Top
 Profile Send private message  
 
PostPosted: Fri Jan 11, 2013 3:37 pm 
Eileen-Class Veteran
User avatar

Joined: Fri Dec 11, 2009 5:25 pm
Posts: 1441
You need to put the variable name into square brackets
Code:
a "you're score : [my_var]"

http://www.renpy.org/doc/html/text.html#interpolating-data


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], xela


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group