Page 1 of 1

Problem with defining.

Posted: Sun Oct 29, 2017 3:24 pm
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.

Re: Problem with defining.

Posted: Sun Oct 29, 2017 3:37 pm
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.

Re: Problem with defining.

Posted: Sun Oct 29, 2017 3:45 pm
by MrLiar
Thank you, everything works now.

Re: Problem with defining.

Posted: Wed Dec 06, 2017 11:43 am
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.

Re: Problem with defining.

Posted: Wed Dec 06, 2017 1:53 pm
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.

Re: Problem with defining.

Posted: Thu Dec 07, 2017 9:48 am
by SypherZent
Oh, I had not seen that. Thanks for sharing, trooper6!
That helps a ton!