[Solved] Points issue

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
BiggieCheese
Newbie
Posts: 3
Joined: Thu Mar 29, 2018 9:37 am
Contact:

[Solved] Points issue

#1 Post by BiggieCheese »

I'm making a dating sim (what a surprise), and obviously I'm using a points system in which you can get one of many endings. I gave my first character a points system and it worked fine. I defined it at the beginning and it was good to go. But then when I gave my second character a points system, it didn't work. I could open the game fine but when it got to a certain point it wasn't able to continue. I defined the points at the beginning, so I really don't know where the issue is.

Code: Select all

While running game code:
  File "game/script.rpy", line 286, in script
    if Yoongi_Points == 0:
  File "game/script.rpy", line 286, in <module>
    if Yoongi_Points == 0:
NameError: name 'Yoongi_Points' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 286, in script
    if Yoongi_Points == 0:
  File "C:\Users\Karina\Downloads\renpy-6.99.14.1-sdk\renpy\ast.py", line 1702, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\Karina\Downloads\renpy-6.99.14.1-sdk\renpy\python.py", line 1843, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\Karina\Downloads\renpy-6.99.14.1-sdk\renpy\python.py", line 1836, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 286, in <module>
    if Yoongi_Points == 0:
NameError: name 'Yoongi_Points' is not defined

Code: Select all

                        jm "Okay guys, there's someone I'd like you to meet!"
                        "The boys settled down, and stared right at you."
                        jm "Let me introduce you to the boys."
                        "Jimin smiled brightly."
                        jump introduction
                        label introduction:
                            jm "Okay, this is Jungkook, he's the youngest."
                            show jungkookneutral at right
                            jk "Nice to meet you!"
                            "Jungkook smiled at you, and gave a quick wave before skipping back to his seat."
                            hide jungkookneutral
                            jm "And this is Taehyung!"
                            show taehyungneutral at right
                            t "Hi..."
                            "Taehyung smiled at you and walked back to his seat."
                            hide taehyungneutral
                            jm "And this is..."
                            j "The best person you will ever meet!"
                            "Jimin sighed."
                            jm "This is..."
                            j "The most... HANDSOME person you will ever meet!"
                            jm "Ji..."
                            show jinneutral at right
                            j "KIM SEOKJIN!"
                            "Jin coughed."
                            j "Good afternoon."
                            "Jin walked up to you and kissed your hand."
                            "You could hear another boy sighing in the background as Jin stood back up."
                            show namjoonneutral 
                            n "Just..."
                            n "Just sit down."
                            j "Hey!"
                            "Jin sat back in his chair and crossed his legs."
                            hide jinneutral
                            jm "Well then, since he's up, let me introduce you Namjoon!"
                            n "Hey, I'm the leader of the crew."
                            "He pronounced crew slightly wrong, and instead said 'gru', making you chuckle."
                            "Namjoon gave you a slight wave and an awkward smile."
                            "He walked back to his seat and sat down."
                            hide namjoonneutral
                            jm "This is Hoseok!"
                            show hoseokneutral
                            h "Hello!"
                            "Hoseok waved at you with both of his hands, and smiled a huge smile."
                            "He then skipped back to his seat in between Namjoon and Jungkook, and sat down."
                            hide hoseokneutral
                            jm "And this is..."
                            if Yoongi_Points == 0:
                                show yoongineutral at right
                                y "Don't worry, I can introduce myself, Chimmy."
                                y "Hey, I'm Yoongi."
                                "Yoongi winked at you, before walking back to his seat."
                                hide yoongineutral
                                jump jiminintroduce
                            if Yoongi_Points == -1:
                                jm "Yoongi!"
                                show yoongineutral at right
                                "Yoongi gave you a short wave and forced smile, before walking back to his seat."
                                hide yoongineutral
                                jump jiminintroduce
                                label jiminintroduce:
                                    show jungkookneutral
                                    show yoongineutral at right
                                    jm "And last but not least, I'm Jimin!"
                                    "Jimin smiled at you."
                                    jm "Hey wait..."

I don't normally go onto forums to ask for help I normally just figure it out myself, but like I said, I really just can't find where the issue is. (Sorry about how the code looks here it's not an issue of indentation I don't think)
Last edited by BiggieCheese on Fri Mar 30, 2018 11:21 am, edited 2 times in total.

User avatar
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

Re: Points issue

#2 Post by Lord Hisu »

You should post the part where the variables are declared.

Also, see that button over the text box with this "</>" when you are typing and answer? Put your code inside that tag if you want it to be indented.

BiggieCheese
Newbie
Posts: 3
Joined: Thu Mar 29, 2018 9:37 am
Contact:

Re: Points issue

#3 Post by BiggieCheese »

Is this enough? If not I can post more, just ask.

Code: Select all

label start:
    $ Jimin_Points = 0
    $ Jin_Points = 0
    $ Hoseok_Points = 0
    $ Namjoon_Points = 0
    $ Jimin_Points = 0
    $ Taehyung_Points = 0
    $ Jungkook_Points = 0
    $ Yoongi_Points = 0
    scene black
    "You lay in your bed, warm and cosy, ready to spend the entire day in bed."
    "You turned to your side and pulled your blanket up over your shoulder."
    "You lay there, trying to fall back asleep when suddenly..."
    m "Wakey wakey eggs and bakey!"

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: Points issue

#4 Post by korova »

Define your variables outside labels (before label start) with "default" keyword

Code: Select all

default Jimin_Points = 0
default Jin_Points = 0
default Hoseok_Points = 0
default Namjoon_Points = 0
default Jimin_Points = 0
default Taehyung_Points = 0
default Jungkook_Points = 0
default Yoongi_Points = 0

label start:

    scene black
    "You lay in your bed, warm and cosy, ready to spend the entire day in bed."
    ## etc.

BiggieCheese
Newbie
Posts: 3
Joined: Thu Mar 29, 2018 9:37 am
Contact:

Re: Points issue

#5 Post by BiggieCheese »

Thanks! It's working now. Sorry if this was really obvious, I just started coding about a week ago. Anyway, thanks again.

Post Reply

Who is online

Users browsing this forum: BBN_VN