Making dialogue be said once player stats are at a set level

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
herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Making dialogue be said once player stats are at a set level

#1 Post by herrmitty »

Basically, I'm doing an assignment for my Science class about atomic structure and elements. In the game, basically, you're a student who's beginning their exams. I want to make it so that in the exam part the Grade Score changes depending on the answers supplied and the dialogue proceeds to change with this. Please help, I'm a newbie at this sorta stuff... :?
(Also, please ignore any typos, this is pretty much a draft of dialogue, I'll go over it later."

Code: Select all

define g = Character('???', color="#1F232F")
define m = Character('You', color="#87ddf6")
define t = Character('Teacher', color="#c8ffc8")
define l = Character('Leah', color="#1F232F")
define e = Character('Ed', color="#c8ffc8")
define a = Character('Arlo', color="#c8ffc8")

label start:
    
$ Grade_Score = 0
    
    
t "Welcome! I'm your teacher and guide for the game ahead."
$ player_name = renpy.input("Before we start, what is your name?")
$ player_name = player_name.strip()
 
t "Nice to meet you, %(player_name)s!"
t "This game is a visual novel, so it follows a set storyline with player's choice along the way. The choices you make affect the end result of the game. When you are given choices, you just need to click on the box with the answer you see fit. Do you understand?"
menu:
  "Sure do!":
    jump understand
  "Not really...":
    jump dontunderstand

label understand:
  t "That's great! I suppose you can start the game now!"
jump game
     
label dontunderstand:
  t "That's okay, but you just did exactly what you need to do! The mechanics in this game are quite simple, so that's about as difficult as it gets."
  t "Well, I suppose you understand now, so we'll head to the game!"
jump game

label game:
    "Time to get up I suppose. It's a school day today."
jump awake

label awake:
    "Now what to do..."
menu:
    "Check calendar":
      jump date1
    "Check phone for messages":
      jump phone1
    "Head to school":
      jump school1

label date1:
 "Hey, it's June 1st. Winter is here at long last!"
jump awake

label phone1:
  "No notifications, what a shame."
jump awake

label school1:
  "Well, time to go I guess!"
jump class1

label class1:
  t "Good morning everyone!"
  t "For the next week, this class will solely be preparing for the exams on the 4th July."
  t "This semester's exams will be on atomic science."
  t "For today's lesson, we will cover the question,'What is an atom?'"
  t "Any ideas?"
menu:
    "I know!":
       jump know1
    "I don't know...":
       jump dontknow1

label know1:
menu:
  "An atom is a form of matter that is made of things with positive, neutral and negative charges.":
    jump rightanswer1
  "An atom is the smallest thing.":
    jump almostrightanswer1
  "An atom is created when lots of molecules join together.":
    jump wronganswer1
  "An atom is the building block of all things.":
    jump rightanswer1

label rightanswer1:
 t "Precisely! To go more in-depth, an atom is a type of matter that is part of everything. For example, the floor is made of atoms, I am made of atoms and you are made of atoms. Atoms are also the components in molecules, which like atoms, are the building blocks of everything."
jump class2

label almostrightanswer1:
 t "Nearly there! An atom is not technically the smallest thing as it is made of smaller components. These are called electrons, neutrons and protons, but we'll go into more detail about that later."
jump class2

label wronganswer1:
 t "Sorry %(player_name)s, but that isn't quite right... A molecule is formed when two or more atoms combine, rather than vice versa."
jump class2

label dontknow1:
 "I have no idea about any of this... I'll let the teacher or someone else explain it."
jump girlraisehand

label girlraisehand:
 g "An atom is a form of matter that is part of everything. My chair is made of atoms, your hair is made of atoms, water is made of atoms. Atoms are the things that make up molecules, another form of matter that everything is made of."
 t "Great explanation!"
jump class2

label class2:
  t "Okay, so school's nearly over, but before then, I'll quickly show you a diagram of an atom."
jump atomdiagram1

label atomdiagram1:
 t "As you can see, around the outside of the centre of the atom is a ring with small circles on it. These circles are called electrons. These electrons give the atom a negative charge."
 t "In the centre of the atom there are two lots of differently coloured circles. The green circles represent neutrons and the red circles represent protons. Neutrons give the atom a neutral charge, note the 'neut' at the beginning, while protons give a positive charge."
 t "Depending on the amount of each circle, the type of atom it will be, or element it will be, will differ."
 t "Don't worry if you don't understand about elements just yet, we'll go more in-depth about them another day."
jump endschool1

label endschool1:
 t "Okay class, time's up, see you tomorrow!"
jump hallway1

label hallway1:
 g "Hey you!"
 "It's someone from class, I wonder what they want?"
 g "My name is Leah! I was just wondering if you were considering any of the after-school clubs here, or even knew about them. They take a bit of time, but they're so worth it! You can make some good friends, which is helpful now with the exams coming up."
menu:
    "Sorry, I'm busy tonight.":
      jump noclub1
    "I may as well, I don't have anything better to do.":
      jump club1

label club1:
 l "Okay, so the clubs we have this week are just study clubs, sadly."
jump clubchoice1

label clubchoice1:
 menu:
     "I'd like to check some out anyway, I need to study":
       jump artclub1
     "I don't feel like going to a club tonight after all.":
       jump noclub1

label artclub1:
 l "That's great! The study club seems like lots of fun~!"
jump inartclub1

label inartclub1:
 "Wow, this place is cool!"
jump meetguy1

label meetguy1:
 g "Hey, you here for study-group?"
menu:
    "Sure am!":
       jump yesart
    "Not today, just looking.":
       jump noart
       
label noart:
 g "Oh, that's a shame. If you change your mind, you can always come back!"
jump clubchoice1

label yesart:
 g "Well, nice to meet you then. My name is Ed, and I'm the leader of the study group today."
 g "If you just sit at the table over there, we can all start."
 $ gift = "Ed"
jump artmontage

label artmontage:
scene black with dissolve

show text "Three hours later" with Pause(1.5)

scene black with dissolve
jump home1

label home1:
 "Going to the study club has made me exhausted... I'll just head to bed earlier tonight."
jump sleep1

label noclub1:
 "Well, I have time on my hands to do what I like now, I guess. I may as well study for the exams."
$ gift = "noEd"
jump studying1

label studying1:
scene black with dissolve

show text "The periodic table is a chart with every type of element discovered recorded down. The periodic table also contains the amount of each proton, neutron and electron required for an atom." with Pause(1.5)

scene black with dissolve
jump sleep1

label sleep1:
 "Well, time for sleep now..."
scene black with dissolve

show text "Next morning..." with Pause(1.5)

scene black with dissolve
jump day2

label day2:
 "*yawn*"
 "Now, what to do..."
menu:
    "Check phone for messages":
      jump phone2
    "Check calendar":
      jump calendar2
    "Head to school":
      jump school343
      
label calendar2:
    "It's Tuesday, July 2nd today."
jump day2

label phone2:
if gift == "Ed":
 m "Oh, Ed sent me a message!"
 
 scene black with dissolve

 show text "Hi! Just wanted to let you know that everyone from art club is having a study group together at the local cafe. Leah will be coming too, don't worry! Anyway, Bye! - Ed" with Pause(1.5)

 scene black with dissolve
if gift == "noEd":
 m "Oh well, nothing again today."
jump day2

label school343:
"Hey, I came just in time, I should probably head to class now."
jump class3

label class3:
t "Good morning! Today in class, we'll be going over what an element is. Just chat for five minutes while I set up the sheet."
l "Hey %(player_name)s! I just wanted to let you know about the purpose of making friends is. I know it may seem irrelevant right now, with exams and all, but it's important as your friends can help you learn in study groups. Most friends hang out every few days and with exams like this, they'll probably all be studying, so you'll get a bit of knowledge out of it all."
l "Also, friends can tell you more about a subject that you won't find in the textbook, which can give you more insight into a subject than studying. Please note though, making friends can take more time to do than to quickly look in a book. In my opinion though, it's so worth it."
if gift == "Ed":
 e "Hey Leah and %(player_name)s! I just wanted to give you a little tip. The term 'element' is used to describe atoms with certain characteristics. For example, An oxygen element has eight protons, neutrons and electrons, while a hydrogen element has seven of each."
jump classstart4

label classstart4:
t "Okay, I'm all set now, you can all quiet down."
t "So, as I said previously, today we'll be talking about what an element is and what the 'periodic table' is."
t "Any ideas?"
menu:
    "I know!":
      jump know3
    "I don't know what any of these things are...":
      jump dontknow3

label dontknow3:
t "Nobody? An element is an element with set characteristics. The periodic table documents all the known elements and how they are formed."
jump afterquestion1

label know3:
menu:
    "An element is like fire, wind, water or air.":
      jump nearlyright2
    "An element is an atom with set characteristics.":
      jump right2
    "The periodic table has a list of all types of molecules.":
      jump wrong

label nearlyright2:
t "Hmmm... Sort of, but not quite right. The periodic table is a reference for all currently known elements and how many protons is required to fit the category of a certain element. The periodic table was made by Dmitri Mendeleev, a Russian chemist. He organised the elements by atomic mass, while nowadays the elements are sorted by atomic numbers, electron configurations and recurring chemical properties."
jump afterquestion1

label right2:
t "Exactly. Another definition that also fits is that an element is something that can't be broken down into simpler chemical substances."
jump afterquestion1

label afterquestion1:
t "Okay so, what is the periodic table and what does it reference?"
t "The periodic table is a chart that orders elements by their atomic number, their electron configuration and their recurring chemical properties."
t "The atomic number of an atom is the amount of the atom's protons. But, as elements are based off of atoms and atoms all have to have the same number of protons, neutrons or electrons so that they are not identified as ions. Therefore, the atomic number of an atom can be used to identify how many electrons an atom has, or even neutrons." 
t "Before, I mentioned elements, so what exactly are they? Elements are substances that is consisting of atoms which all have the same number of protons. They can't be broken down into smaller components, they are indivisible."
t "Anyway, class is close to finishing, so I'll put a poster up of the periodic table and we can have a discussion about it and then we can move on."
jump periodictable1

label periodictable1:
t "So, as you can see, all the little boxes on the table have letters and numbers in them. The letters signify what element is there, while the numbers are their atomic numbers."
jump neonperiodictable

label neonperiodictable:
t "Here's a better look at one of the elements on the periodic table, more namely number 10, or Neon. So, what can we see on the box for Neon? There's a number with decimals at the bottom, a small number 10 and the letters Ne. We can also see the box is coloured purple, signifying that the element is a 'halogen'."
t "A halogen is a category of elements. There are six ways to identify a halogen. The first is that when a halogen is combined with hydrogen, every single type creates an acid."
t "The second identifying feature is that all Halogens are fairly toxic."
t "The third is they all readily combine with metals to form salts."
t "The fourth is that they all have seven valence electrons in their outer shell."
t "The fifth is that they are all highly reactive and electronegative."
t "And for the sixth and final feature, is that they all exist as two atoms when in their pure form."
jump neonperiodictable2

label neonperiodictable2:
t "So, that may be a bit confusing as of yet, but, we won't be going into the catergories of the periodic table on the tests."
t "Back to the picture, as we can see, another identifying feature of the boxes on the periodic table is the number at the very bottom. This a number's atomic mass. Pretty self-explanatory, I would say, but yeah, it's an atom's mass. You can find the approximate atomic mass of a number by adding together the total of protons and neutrons."
t "So, we have seen all the aspects of the periodic table's boxes."
t "To summarise it, all of the numbers in the boxes sum up the amount of protons, neutrons and atoms an element has in different ways"
jump classendingnow

label classendingnow:
t "Well, that's all the time we have for today tomorrow!"
if gift == "Ed":
     jump studygroup
if gift == "NoEd":
     jump home6

label studygroup:
e "Hey %(player_name)s!"
l "Hi!"
g "Nice to meet you~!"
menu:
    "Ask the unknown person their name":
      jump newfriend1
    "Just sit down":                    
      jump nofriend

label newfriend1:
g "My name is Arlo!"
a "I'm guessing yours is %(player_name)s?"
a "Ed and Leah talk about you all the time!"
a "Anyway, I suppose we should start!"
$ gift = "Arlo"
jump learning3

label nofriend:
e "Anyway, let's get started!"
jump learning3

label learning3:
scene black with dissolve

show text "Quarks are the building blocks of protons and neutrons. A proton is made of three quarks, two 'up' quarks and one 'down' quark." with Pause (4.0)

scene black with dissolve
jump home7

label home6:
"What should I do now?"
menu:
    "Study":
      jump study4
    "Sleep":
      jump sleep5
      
label sleep5:
"*yawn*"
"I suppose I really should go to bed now..."
jump newday5

label study4:
scene black with dissolve

show text "Francium is the rarest element. There are probably no more than a few ounces of it on the world at any one time."

scene black with dissolve
jump studymontage12

label studymontage12:
scene black with dissolve

show text "Three hours later..."

scene black with dissolve
jump sleep5

label home7:
"*yawn*"
"Wow, studying sure has made me tired. Glad I hung out with my friends though."
jump newday5

label newday5:
"Now what to do today..."
menu:
    "Check phone":
     jump phonenothing2
    "Check calendar":
     jump calendar3
    "Go to school":
     jump school3
     
label phonenothing2:
"No messgaes, oh well..."
jump newday5

label calendar3:
"It's June 3rd. Two days left till exams."
jump newday5

label school3:
"Time to go, I guess..."
jump inclass3

label inclass3:
t "Hey everybody!"
t "Just a reminder that the exams are in two days. Remember to study everyone!"
jump classpart1

label classpart1:
t "So, today, we'll be revising what we've already learnt."
t "This is more of a discussion task, to get you to understand some of the basic concepts."
t "Does anyone remember what the first element on the periodic table is?"
menu:
    "I know!":
     jump trivia24
    "I don't know...":
     jump notrivia24

label trivia24:
menu:
    "Hydrogen":
     jump rightanswerbuddyjim
    "Helium":
     jump wronganswerbuddyjoe
    "Oxygen":
     jump wronganswerbuddyjoe1

label rightanswerbuddyjim:
t "Correct! Hydrogen is the first element of the periodic table, with an atomic number of 1."
jump classpart2

label wronganswerbuddyjoe:
t "Sorry, but not right. Helium is the second element on the periodic table, with an atomic number of 2. Hydrogen is the first element."
jump classpart2

label wronganswerbuddyjoe1:
t "Oxygen is number 8 on the periodic table, not first. Hydrogen is the correct answer."
jump classpart2

label notrivia24:
t "No-one? Oh well. Hydrogen is the first element of the periodic table. Helium is second and Oxygen is eighth."
jump classpart2

label classpart2:
t "Okay, so let's go through what an atom is."
t "Anyone know?"
menu:
    "An atom is what makes up everything.":
      jump rightanswer23746
    "An atom is what a molecule is made of.":
      jump rightanswer23746
    "An atom is another word for molecule.":
      jump wronganswer23746
    "I don't know.":
      jump idek

label rightanswer23746:
t "That's exactly right! An atom is what everything is made up of, including molecules!"
jump classpart3

label wronganswer23746:
t "Hmmm... Not right. An atom is what makes up a molecule. They're not the same thing."
jump classpart3

label idek:
l "An atom is what makes up everything, even molecules! It is the building block of all things."
jump classpart3

label classpart3:
t "The periodic table orders elements by what?"
menu:
    "Alphabetical order.":
      jump wrong1234
    "The amount of protons":
      jump right123
    "The amount of neutrons":
      jump wrong123
    "The weight of the atom":
      jump wrong123

label right123:
t "Precisely! But, please note, in an atom, the amount of protons and electrons is the same."
jump classpart4

label wrong123:
t "Sort of, but not really. If we're being specific, the atomic number of na atom measures it's protons, not neutrons or electrons."
jump classpart4

label classpart4:
t "Okay, so I just wanted to let you all know that tomorrow is a day off for you all to revise."
t "Then, the next day, it's the exam."
t "Good luck, and goodbye!"
jump home142

label home142:
"I suppose I should study tonight."
jump studyin123123

label studyin123123:
scene black with dissolve

show text "There are 118 currently known elements." with Pause (2.0)

scene black with dissolve
jump sleep1286

label sleep1286:
"Well, night time now. May as well sleep."
jump nextday18746

label nextday18746:
"Now, no school today... What shall I do?"

if gift == "Ed":
  menu:
    "Meet up with Ed":
      jump EdDay
    "Study":
      jump studyday
    "Sleep":
      jump noday
      
if gift == "NoEd":
    menu:
        "Study":
            jump StudyDay
        "Sleep":
            jump noday
            
label EdDay:
"I should check if I can study with Ed, two heads are always better than one!"
jump callEd

label noday:
"Should I really sleep the whole day and not study? It may affect my exam results..."
menu:
    "I'm so tired, I'm going to bed.":
      jump EXAMDAY43243232
    "I need to study for this test.":
      jump nextday18764

label callEd:
scene black with dissolve
 
show text "Hey! I can hang out to study today if you want. Anyway, bye!" with Pause (7.0)

scene black with dissolve
jump StudyDayWithED

label StudyDay:
scene black with dissolve

show text "A quark is what scientist believe make up protons and neutrons. Rather than differing the quarks by their charges, quarks are differenciated by either being 'up' quarks or 'down' quarks. For example, a proton has two 'up' quarks and one 'down' quark." with Pause (7.0)

scene black with dissolve
jump sleepnowovereveryone

label sleepnowovereveryone:
"Gosh, I'm so tired today. I'm just gonna head to bed..."
jump EXAMDAY43243232

label StudyDayWithED:
e "Hey! I suppose we should get started, tomorrow is a big day."
scene black with dissolve

show text "The reason wateris so movable and scultable with solids are not is because of the different densities of the molecules. In solids, molecules are tightly packed with barely any room to move, which is why for instance, you cannot bend a table. In liquids on the other hand, there are still lots and lots of molecules, they just aren't so tightly joined, so they are able to move more freely. Gases are just the same as water, but even less dense." with Pause (12.0)

scene black with dissolve
jump sleepnowovereveryone

label EXAMDAY43243232:
"*yawn*"
"I'm up nice and early this morning!"
"What to do now?"
menu:
    "Check calendar":
      jump ITSEXAMDAYTODAYWOOP
    "Check phone":
      jump GOODLUCKYALL
    "Go to school":
      jump EXAMTIMEBESTWISHES

label ITSEXAMDAYWOOP:
"Hey it's the 4th today, time for exams when I get to school!"
jump EXAMDAY43243232

label GOODLUCKYALL:
if gift == "Ed":
      scene black with dissolve
    
      show text "Hi! Just wanted to wish you luck at the exams today! - Ed" with Pause (7.0)
    
      scene black with dissolve
      jump EXAMDAY43243232

if gift == "Arlo":
        scene black with dissolve
    
        show text "Hi! Just wanted to wish you luck at the exams today! - Ed" with Pause (7.0)
    
        show text "Hey! Just wanted to say good luck! - Arlo" with Pause (5.0)
    
        scene black with dissolve
    
        jump EXAMDAY43243232
    
if gift == "NoEd":
        scene black with dissolve
    
        show text "Hi! Wanted to say good luck for the exams today, have fun! - Leah" with Pause (7.0)
    
        scene black with dissolve
        jump EXAMDAY43243232
    
label EXAMTIMEBESTWISHES:
t "Good morning everyone! I know that you are all very nervous about the big exams today, and I just wanted ot let you all know that you don't need to stress too much. Just have funand do your best!"
jump testquestion1

label testquestion1:
"How do you measure the mass of an atom?"
menu:
    "A. Add the protons and the electrons.":
       $ Grade_Score -= 1
       jump testquestion2
    "B. Add the protons and the neutrons.":
       $ Grade_Score += 1
       jump testquestion2
    "C. Add the neutrons and the electrons.":
       $ Grade_Score -= 1
       jump testquestion2
       
label testquestion2:
"What does the periodic table document?"
menu:
    "A. It measures all the currently known molecules" :
        $ Grade_Score -= 1
        jump testquestion3
    "B. It documents all the currently known atoms":
        $ Grade_Score -= 1
        jump testquestion3
    "C. It documents all the currently known elements.":
        $ Grade_Score += 1
        jump testquestion3

label testquestion3:
"How many elements are on the periodic table?"
menu:
    "A. 143":
        $ Grade_Score -= 1
        jump testquestion4
    "B. 118":
        $ Grade_Score += 1
        jump testquestion4
    "C. 123":
        $ Grade_Score -= 1
        jump testquestion4
        
label testquestion4:
"What is the centre of the atom called?"
menu:
    "A. Nucleus":
        $ Grade_Score += 1
        jump testquestion5
    "B. Bond":
        $ Grade_Score -= 1
        jump testquestion5
    "C. Centre":
        $ Grade_Score -= 1
        jump testquestion5

label testquestion5:
"What charge does a neutron have?"
menu:
    "Positive":
        $ Grade_Score -= 1
        jump testquestion6
    "Negative":
        $ Grade_Score -= 1
        jump testquestion6
    "None":      
        $ Grade_Score -= 1
        jump testquestion6

label testquestion6:
"What is the second element on the periodic table?"
menu:
    "Hydrogen":
        $ Grade_Score -= 1
        jump testquestion7
    "Helium":
        $ Grade_Score += 1
        jump testquestion7
    "Water":
        $ Grade_Score -= 1
        jump testquestion7

label testquestion7:
"What is a molecule?"
menu:
    "The combination of multiple subatomic particles":
        $ Grade_Score -= 1
        jump testquestion8
    "When two or more atoms join together":
        $ Grade_Score += 1
        jump testquestion8
    "The matter that makes up atoms":
        $ Grade_Score -= 1
        jump testquestion8

label testquestion8:
"What are the name of subatomic particles that protons and neutrons are made of?"
menu:
    "Ions":
        $ Grade_Score -= 1
        jump testquestion9
    "Photon":
        $ Grade_Score -= 1
        jump testquestion9
    "Quark":
        $ Grade_Score += 1
        jump testquestion9

label testquestion9:
"What are the types of quarks?"
menu:
    "Up and Down":
        $ Grade_Score += 1
        jump testquestion10
    "Positive and Negative":
        $ Grade_Score -= 1
        jump testquestion10
    "None of the above":
        $ Grade_Score -= 1
        jump testquestion10

label testquestion10:
"What catergory does water (H2O) fit under?"
menu:
    "Molecule":
        $ Grade_Score += 1
        jump testscores
    "Atom":
        $ Grade_Score -= 1
        jump testscores
    "Element":
        $ Grade_Score -= 1
        jump testscores

label testscores:
t "Okay, so now that we've all finished, I'll take your tests and quickly mark them."
t "Good luck!"
scene black with dissolve

show text "After the marking..."

scene black with dissolve
jump results

label results:
  if Grade_Score <= 10:
    t "Congratulations %(player_name)s! You got the perfect score!"
  if Grade_Score <= 9:
    t "%(player_name)s! You got 9/10, almost perfect!"
  if Grade_Score <= 8:
    t "Pretty good %(player_name)s, you got 8/10."
  if Grade_Score <= 7:
    t "That's a decent score %(player_name)s, you got 7/10."
  if Grade_Score <= 6:
    t "You passed, %(player_name)s, you got 6/10."      
  if Grade_Score <= 5:
    t "That's pretty good, I guess. You got 5/10."
  if Grade_Score <= 4:
    t "There's room for improvement, but good try. You got 4/10."
  if Grade_Score <= 3:
    t "You tried, I suppose. You got 3/10."
  if Grade_Score <= 2:
    t "I think you could do better next time. You got 2/10."
  if Grade_Score <= 1:
    t "I though you could do better than this. You got 1/10."
  if Grade_Score <= 0:
    t "Try harder next time. You scored 0/10."


User avatar
Iylae
Regular
Posts: 73
Joined: Sat Jan 09, 2016 6:57 am
Location: Cornwall, UK
Contact:

Re: Making dialogue be said once player stats are at a set l

#2 Post by Iylae »

Whilst I don't really understand what problems you're having with this after a summary look over, what I can suggest is... you probably shouldn't lose a mark by getting a question wrong. I don't know of any academic tests that do that.

e.g.

Code: Select all

label testquestion1:
"How do you measure the mass of an atom?"
menu:
    "A. Add the protons and the electrons.":
       $ Grade_Score -= 1
       jump testquestion2
    "B. Add the protons and the neutrons.":
       $ Grade_Score += 1
       jump testquestion2
    "C. Add the neutrons and the electrons.":
       $ Grade_Score -= 1
       jump testquestion2
If you answer A or C for this first question you're now on -1 marks. Surely it should just be:

Code: Select all

label testquestion1:
"How do you measure the mass of an atom?"
menu:
    "A. Add the protons and the electrons.":
        pass
    "B. Add the protons and the neutrons.":
       $ Grade_Score += 1
    "C. Add the neutrons and the electrons.":
       pass
    jump testquestion2
(Note I used the pass keyword and moved the jump to the end just for easier reading.)

The reason I came to this conclusion is you set Grade_Score to 0 at the start, but the results measure from 0-10. This means if a user is getting negative marks from questions they may not have 0-10 in their Grade_Score.
Image
  If we are what we repeatedly do, then good coding is not an act, but a habit

herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Re: Making dialogue be said once player stats are at a set l

#3 Post by herrmitty »

Thanks, I'll try!

herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Re: Making dialogue be said once player stats are at a set l

#4 Post by herrmitty »

Okay, sadly, this still didn't change the ranking dialogue values, but it's probably cleared a lot up, so thanks anyway :)

User avatar
Iylae
Regular
Posts: 73
Joined: Sat Jan 09, 2016 6:57 am
Location: Cornwall, UK
Contact:

Re: Making dialogue be said once player stats are at a set l

#5 Post by Iylae »

So what actually happens when you get to the results label?
Image
  If we are what we repeatedly do, then good coding is not an act, but a habit

herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Re: Making dialogue be said once player stats are at a set l

#6 Post by herrmitty »

Pretty much, it just goes through all of the 10/10, 9/10 etc. stuff rather than taking into account the grade applied.

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Making dialogue be said once player stats are at a set l

#7 Post by korova »

I suggest this

Code: Select all

label results:
  if Grade_Score <= 0:
    t "Try harder next time. You scored 0/10."
  elif Grade_Score <= 1:
    t "I though you could do better than this. You got 1/10."
  elif Grade_Score <= 2:
    t "I think you could do better next time. You got 2/10."

#etc .....

  elif Grade_Score <= 9:
    t "%(player_name)s! You got 9/10, almost perfect!"
  else Grade_Score <= 10:
    t "Congratulations %(player_name)s! You got the perfect score!"
for now, if you have, say, 5, your first test chechs that you have 10 or under, 5 complies, and you get the 10 answer, plus the 9... etc till 5 and the programme makes the 10 tests.

It should stop when it finds the right condition (this is what elif and else are for)

Asks for details if my explanations are not clear.

herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Re: Making dialogue be said once player stats are at a set l

#8 Post by herrmitty »

Thank you all so much! It works perfectly now and I can finally add the pictures. Thanks!

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Making dialogue be said once player stats are at a set l

#9 Post by korova »

I just realized I made a mistake in the code I provided.
The last clause should be else with nothing else, like that

Code: Select all

  elif Grade_Score <= 9:
    t "%(player_name)s! You got 9/10, almost perfect!"
  else:
    t "Congratulations %(player_name)s! You got the perfect score!"
(no need to test the last condition, as you already tried all the other possibilities at this point.)

herrmitty
Newbie
Posts: 6
Joined: Sun Aug 07, 2016 5:59 am
Tumblr: awildsombrerocatapproaches
Contact:

Re: Making dialogue be said once player stats are at a set l

#10 Post by herrmitty »

Don't worry, i did that much myself. I really appreciate all y'all help!

Post Reply

Who is online

Users browsing this forum: piinkpuddiin