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 »

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: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Problem with defining.

#2 Post by mikolajspy »

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 »

Thank you, everything works now.

User avatar
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

Re: Problem with defining.

#4 Post by SypherZent »

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: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Problem with defining.

#5 Post by trooper6 »

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 (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

Re: Problem with defining.

#6 Post by SypherZent »

Oh, I had not seen that. Thanks for sharing, trooper6!
That helps a ton!
Creator of Multiverse Heroes & Space Hamster in Turmoil

Want me to code your game?
Check my services thread!

Post Reply

Who is online

Users browsing this forum: No registered users