Page 1 of 1

Help Setting Values?

Posted: Thu Jan 04, 2018 8:55 pm
by Mercenary5
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.

Re: Help Setting Values?

Posted: Mon Jan 08, 2018 4:12 am
by nature1996
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