Problem with defining.

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
MrLiar
Newbie
Posts: 2
Joined: Sun Oct 29, 2017 3:14 pm
Contact:

Problem with defining.

#1 Post by MrLiar » Sun Oct 29, 2017 3:24 pm

Hello. I got a problem. I've been writing my game and I added $ Christ_pts = 0 The engine does not see it and says "Christ_pts" is not defined. What am I doing wrong? PS. Spelling is correct, and all of the $s are in the same vertical line, and the rest works.

mikolajspy
Regular
Posts: 94
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Jake's Love Story
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Problem with defining.

#2 Post by mikolajspy » Sun Oct 29, 2017 3:37 pm

You need to add

Code: Select all

 default Christ_pts = 0 
somewhere (for example at the top of script.rpy), and when you want to change it, then:

Code: Select all

$ Christ_pts += 1 #adds 1 to variable
https://www.renpy.org/doc/html/python.h ... -statement

PS: I think that questions like these should be in "Questions and Annoucments" section of forum.

MrLiar
Newbie
Posts: 2
Joined: Sun Oct 29, 2017 3:14 pm
Contact:

Re: Problem with defining.

#3 Post by MrLiar » Sun Oct 29, 2017 3:45 pm

Thank you, everything works now.

User avatar
SypherZent
Regular
Posts: 143
Joined: Fri Sep 02, 2016 3:14 am
Projects: https://www.amazon.com/Kigaea-Effervesc ... 1483598383
Contact:

Re: Problem with defining.

#4 Post by SypherZent » Wed Dec 06, 2017 11:43 am

The Ren'Py engine used to allow the methodology of

1) define variable prior to label start
2) at label start, changing the variable causes the engine to internally recognize it

^ This methodology no longer works since Ren'Py v6.99.13 for me.

Is this intended, or is this a bug in Ren'Py new version?

Should it be absolutely necessary to use default from now on, as define no longer works as it used to? I have been searching documentation but it doesn't seem like "default" is support to eliminate the old usage of "define" to create variables. I'm having odd behavior with this one. I can switch to "default" and it will work, but this seems like unintended functionality (the old method breaking), and I figured I'd ask if it is intentional or not, that the old method broke?

Thanks.
Last edited by SypherZent on Thu Dec 07, 2017 9:48 am, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3066
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Problem with defining.

#5 Post by trooper6 » Wed Dec 06, 2017 1:53 pm

According to PyTom in this thread here: viewtopic.php?p=464232#p464232

You should use default for variables that change, and reserve define that things that won’t change like image definitions or character definitions.
A Close Shave:
*Last Thing Done (Jul 7) Finished Emotion Matrix for Joint Customer Sprite.
*Currently Doing: Print Matrices, & decide emotions to use for Joint Sprite, think about blinking and lip flap. Maybe also about TransitionConditionSwitch?
*First Next thing to do: Code in all the sprite emotion and camera movement for Close Shave Sprite Sections
*Next Thing to Do: Code in all CG and special animation stuff
*Other Next Thing: Do SFX
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
SypherZent
Regular
Posts: 143
Joined: Fri Sep 02, 2016 3:14 am
Projects: https://www.amazon.com/Kigaea-Effervesc ... 1483598383
Contact:

Re: Problem with defining.

#6 Post by SypherZent » Thu Dec 07, 2017 9:48 am

Oh, I had not seen that. Thanks for sharing, trooper6!
That helps a ton!

Post Reply

Who is online

Users browsing this forum: No registered users