Defining Error with Relationship Points (Pending)

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
ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Defining Error with Relationship Points (Pending)

#1 Post by ladilol »

I have been trying to figure this out by looking over similar questions on here, but have yet to solve my problem. When I try to apply relationship points to one of the characters, it keeps saying"

NameError: name 'parihan_points' is not defined

I'm unsure if this is a problem in where I put the 'definition' or not, but I've tried placing the definition:

Code: Select all

$ parihan_points = 0
under the init python label, right under the start label, and under the first menu choice. No matter where I put it, it keeps saying that it's undefined. I would be very thankful if someone could help me soon.

If you would like me to post text, please tell me exactly what parts you need, because I do have a lot of text typed up already.
Last edited by ladilol on Thu Jan 31, 2013 3:01 am, edited 2 times in total.

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Defining Error with Relationship Points

#2 Post by jghibiki »

Read this specifically the part under "Implementing a Point-Based Game"
_______________________________________
jghibiki
Web/Twitter/Tumblr

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points

#3 Post by ladilol »

Thank you for the link but that's exactly what I've been doing, yet it's not working.

Code: Select all

# The game starts here.
label start:
    $ parihan_points = 0
Then there's text and character introductions in between

Code: Select all

    label laugh:
        $ parihan_points += 5
        $ freak_out = True

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Defining Error with Relationship Points

#4 Post by jghibiki »

Try initializing the variables outside of a label

Code: Select all

$myVar = 0
    label changeVar:
    $myVar += 1

    return
Otherwise you can try using and init block: read it HERE I don't think this would work very well though.
_______________________________________
jghibiki
Web/Twitter/Tumblr

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points

#5 Post by ladilol »

It unfortunately didn't work and the init method is a little too complicated for me at my beginning level. Is there any other advice you could offer me?

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Defining Error with Relationship Points

#6 Post by jghibiki »

Hm... Try posing your entire code, minus all of the text lines except for one or two to show that there is a block of it(text) there
_______________________________________
jghibiki
Web/Twitter/Tumblr

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points

#7 Post by ladilol »

Code: Select all

# The game starts here.
label start:
    $ parihan_points = 0
    scene black

    "{i}{size=-5}{cps=20}When I was younger, my mother always told me…{/cps}{/size}{/i}"

Code: Select all

    menu:
        "Calm down already!":
            jump dissapoint

        "Keep freaking out":
            jump laugh

Code: Select all

    label laugh:
        $ parihan_points += 5
        $ freak_out = True
        
        "{size=-5}{cps=20}I tried desperately to calm down but- I. Just. Couldn't. {i}Stop{/i}.{/cps}{/size}"

        k "{size=-5}{cps=20}\"ADFGAhjtnpha'dgmhblfd;ajtophajfdlbdlvbfgasdffffff-\"{/cps}{/size}"
Is that enough? <:

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Defining Error with Relationship Points

#8 Post by jghibiki »

I have to admit I'm stumped... maybe try

Code: Select all

label laugh:
    $ parihan_points = 0
    $ parihan_points += 5
That's pretty much a shot in the dark but the only thing that I can think of is that maybe the variables aren't being recognized globally.
If the above doesn't work then I'm not sure what else to tell you :/
_______________________________________
jghibiki
Web/Twitter/Tumblr

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points

#9 Post by ladilol »

That seems to have worked! Thank you so much!

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Defining Error with Relationship Points (Solved)

#10 Post by jghibiki »

Hmm well unfortunately that is probably only a temporary fix. I think what might be happening is that you aren't able to access variables that were defined in a different label. So you might have trouble with that still. :/
_______________________________________
jghibiki
Web/Twitter/Tumblr

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points (Solved)

#11 Post by ladilol »

Ah you're right. It keeps saying that it's not defined.... This is really distressing... Do you think that I'll have to redo everything in order to get the result I want?

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Defining Error with Relationship Points (Solved)

#12 Post by Anima »

Labels don't have their own scope, any variable you define in a label will be global.
Never define a variable in an init block, since it will lead to problems with the save state. There are a few exceptions, but it's a useful rule of thumb.
Do you have the same problem with other variables?
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

ladilol
Newbie
Posts: 7
Joined: Wed Jan 30, 2013 10:16 pm
Contact:

Re: Defining Error with Relationship Points (Solved)

#13 Post by ladilol »

Yes actually, when I try to do

Code: Select all

if
statements

Post Reply

Who is online

Users browsing this forum: No registered users