define vs $ question

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
VorrAkkagi
Newbie
Posts: 21
Joined: Tue Dec 11, 2018 5:41 am
Contact:

define vs $ question

#1 Post by VorrAkkagi » Sat Dec 22, 2018 12:13 am

Ok so another noob question (the documentation doesn't describe this well enough for me):

A 'define' statement sets a value permanently to something? And so does the '$' option.
example:
define wisdom = 10

Now can the 'wisdom' be modified later?
I try:
define wisdom += 1 ...and get an error

But if I try:
$ wisdom = 10 then later when I use $ wisdom += 1 I get an error as well.

So I'm baffled as to how I'm supposed to use these.
My goal is to be able to set up the character's abilities, etc. Then modify them when conditions are met.

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

Re: define vs $ question

#2 Post by trooper6 » Sat Dec 22, 2018 12:38 am

First, outside of any label, you initialize your variables.
Use define, if the variable will not change
Use default, if the variable will change
$ is an indicator that you will be using a line of python code. You must use python to change variables...so that is what that is doing.

So...

Code: Select all

default wisdom = 10
default strength = 10

label start:
    "You may increate one of your two stats."
    menu:
        "Which do you increase?"
        "Strength":
            $ strength += 1
        "Wisdom":
            $ wisdom += 1
    "Thanks. Game over."
    return
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

VorrAkkagi
Newbie
Posts: 21
Joined: Tue Dec 11, 2018 5:41 am
Contact:

Re: define vs $ question

#3 Post by VorrAkkagi » Sat Dec 22, 2018 5:17 am

'default' ... LOL
been using the wrong one all along!
Thanks a million Trooper6!!! This will relieve me of a big headache =)
And your explanation helps even more. Clear and concise educating of the uneducated!

Post Reply

Who is online

Users browsing this forum: Gushi