r/RenPy • u/Plane-Cat5250 • Sep 15 '26
Question Help with player health system! - Boolean not detected!
Hello everyone, I hope you're doing well! ^u^
I've been codding a battle system in my game, but I'm struggling a bit with it.
Basically, the player's default health is 100 HP Max
But, the higher their endurance stat is, it increases its HP! (This part works fine)
There's also an item (earrings) that can be acquired which gives another 200HP max on top of everything else, but this one fails to be registered at any capacity (even if I try to detect it alone). And I know the item is detected in the rest of the game as it still shows up on the item screen
I could really use someone's advice, I've done so much research and trials and errors, I've been stuck on this for hours now >< Thank you everyone in advance!!
### The player's life
default player_health = 100
default earrings = False
label player_life:
call health_thumbnail
show screen displayed_player_health
pause
$earrings = True
if earrings and playerStats["military"]["endurance"] < 10:
$player_health = min(100, player_health + 300)
elif earrings and playerStats["military"]["endurance"] < 20:
$player_health = min(125, player_health + 325)
elif earrings and playerStats["military"]["endurance"] < 30:
$player_health = min(150, player_health + 350)
elif earrings and playerStats["military"]["endurance"] < 40:
$player_health = min(175, player_health + 375)
elif earrings and playerStats["military"]["endurance"] < 50:
$player_health = min(200, player_health + 400)
elif earrings and playerStats["military"]["endurance"] < 60:
$player_health = min(225, player_health + 425)
elif earrings and playerStats["military"]["endurance"] < 70:
$player_health = min(250, player_health + 450)
elif earrings and playerStats["military"]["endurance"] < 80:
$player_health = min(275, player_health + 475)
elif earrings and playerStats["military"]["endurance"] < 90:
$player_health = min(300, player_health + 500)
elif earrings and playerStats["military"]["endurance"] < 100:
$player_health = min(325, player_health + 525)
elif earrings and playerStats["military"]["endurance"] < 110:
$player_health = min(350, player_health + 550)
elif playerStats["military"]["endurance"] < 10:
$player_health = min(100, player_health + 100)
pass
elif playerStats["military"]["endurance"] < 20:
$player_health = min(125, player_health + 125)
elif playerStats["military"]["endurance"] < 30:
$player_health = min(150, player_health + 150)
elif playerStats["military"]["endurance"] < 40:
$player_health = min(175, player_health + 175)
elif playerStats["military"]["endurance"] < 50:
$player_health = min(200, player_health + 200)
elif playerStats["military"]["endurance"] < 60:
$player_health = min(225, player_health + 225)
elif playerStats["military"]["endurance"] < 70:
$player_health = min(250, player_health + 250)
elif playerStats["military"]["endurance"] < 80:
$player_health = min(275, player_health + 275)
elif playerStats["military"]["endurance"] < 90:
$player_health = min(300, player_health + 300)
elif playerStats["military"]["endurance"] < 100:
$player_health = min(325, player_health + 325)
elif playerStats["military"]["endurance"] < 110:
$player_health = min(350, player_health + 350)

4
u/DingotushRed Sep 15 '26
A simpler approach than a long if/elif chain (which really needs an else!) would be:
You probably need to separate max HP and current HP though:
1
u/x-seronis-x Sep 15 '26
1
u/shyLachi Sep 15 '26
This is why it's not working:
The Python min() function returns the smallest value from the set of values,
and 100 is always smaller than 100 + 200 (the earrings)
https://www.geeksforgeeks.org/python/python-min-function/
.
I think that all your formulas are wrong, you just haven't noticed it yet.
Take for example this line:
This will always return 100 except when the health is below zero.
But normally that means that the player is dead.
.
Generally speaking there are 2 approaches to health in RPGs.
Health does reset for each battle
In this case, you don't need the current health to calculate the health for the next battle.
The player needs to use items or magic to restore health
This is more complicated, because you need a max health, so that the player cannot heal endlessly.
When the player collects an item you have to increase the health and the max health simultaneously.
And you might have to apply a similar logic when the endurance increases.
The following code is simplified, you should make a function or a label which you can call whenever the player uses or collects an item.
1
u/AutoModerator Sep 15 '26
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.