How to make a renpy variable based on numbers work.

Mephistofeles

Active Member
Jul 9, 2017
684
790
I seem to be missing something, because when i gave the player the choice of making a decition that increase the variable ("loyalty"), and then give consequences for that, it always gave me the same answer.
The code is somehting like this.
menu:
"Give an inspirational speech.":
$ loyalty += 1
"Dont give it."

(...a lot more of the script)

if loyalty < 1:
"They look at you with devotion. Your little speech last night make an impact and Rasgor probably had something else to do with it. While you probe worthy in the next incursions, they will be no question about their loyalty."

else:
"They look at you with distrust. Your little speech last night make an impact, and not a good one. While fear can be usefull, it is better if they obey you because they want to. You have to do something about this too." (THE GAME ALWAYS PROCED TO THIS ANSWER, EVEN WHEN YOU CHOOCE THE OPTION THAT IS SUPPOSED TO GIVE YOU LOYALTY POINTS.)

I have the default loyalty defined as
define loyalty = 0
Maybe that has something to do.
Any help is apreciated, sorry for my bad english.
 

Maikie

New Member
Jun 9, 2019
2
1
Are you trying to check if loyalty is bigger than 1?

Let's say:

Python:
loyalty = 0
And then we add:

Code:
loyalty += 1
We get:

Code:
loyalty = 1

In your message:

if loyalty < 1:
You are checking if loyalty is LESS THAN 1 so it will always give you the same answer if you've chose the add loyalty option.

If you want to check if it's MORE THAN 1 then it's below:
Code:
loyalty = 0

# Choose to add loyalty
loyalty += 1

if loyalty >= 1:
# ADD LOYALTY MESSAGE HERE

else:
# ADD NO LOYALTY MESSAGE HERE
quick edit:

Saw mistake with comparator.

Here are comparators:

MORE THAN X
1 > x

LESS THAN X
1 < x

MORE THAN OR EQUAL:
1 >= x

LESS THAN OR EQUAL:
1 <= x
 
  • Heart
Reactions: Mephistofeles

Lucky Guerrilla

Newbie
Game Developer
Jan 26, 2021
98
648
You should also describe variables that change with "default" rather than "define".

default loyalty = 0

not

define loyalty = 0

 
  • Heart
Reactions: Mephistofeles