Help Setting Values?

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
Mercenary5
Newbie
Posts: 1
Joined: Thu Jan 04, 2018 8:50 pm
Contact:

Help Setting Values?

#1 Post by Mercenary5 » Thu Jan 04, 2018 8:55 pm

Hi guys! This is probably an easy one, but I am new to coding and I couldn't find the answer in the tutorial. I'd like to assign variables to the Player Characters strength, speed, and relationship with other characters.

Any help is appreciated, sorry the question is so simple/stupid.

nature1996
Newbie
Posts: 20
Joined: Wed Jun 21, 2017 10:35 am
Contact:

Re: Help Setting Values?

#2 Post by nature1996 » Mon Jan 08, 2018 4:12 am

There is many way to do so, and even if I personally also have difficulty with the subject, I will try to help.

From what I got, there is three major way to create variable:
1-the initialization block

Code: Select all

init:
    $strength=5.0
    $defence=5.0 
I believe the problem with that principle is the you variable might not be save (this is one of the point I have dificulty understand, as I believe they sometime do).

2-default
The usually recommended method from what I've heard:

Code: Select all

default strength=5.0
default defence=5.0
This will set the variable to that value if no value is given in the save file (or for a new game). I was once recommended to always use that: viewtopic.php?f=8&t=44567&p=458047#p458054

3-define
If I remember well, this is recommended for variable that doesn't varies as it is not saved, or something like that.

Code: Select all

define strength=5.0
define defence=5.0
I believe this is principally supposed to be used to create character.


In any case once that's done, you can interact with it later on by starting a python line by a starting it by a $

Code: Select all

$HP=HP-strength/defence
or by using logic statement:

Code: Select all

if defence==5:
In the end, you will generaly find more information in the manual, especially using the search function. You might need to go over a few article before finding what you want, but I almost always find what I need there.

Hope I could help

Post Reply

Who is online

Users browsing this forum: Remix