Problem with health points

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
AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

Problem with health points

#1 Post by AlexCLD »

Hi everybody, I have a problem with the points on Ren'py:

Code: Select all

init:
    
   $ player_points = 100
   $ player_max = 100

and even when the label start:

label start:

   $ player_points = 100
   $ player_max = 100

And here:

    frame:
        has vbox 
        text "Your health: [player_points]%"              
        textbutton "Return" action Return()



I want to put health points on the game, but when I'm playing I can have more than the maximum set:

Image

What am I doing wrong? :oops:

Uchiha Echinox
Newbie
Posts: 14
Joined: Fri Feb 13, 2015 9:17 am
Contact:

Re: Problem with health points

#2 Post by Uchiha Echinox »

replace

Code: Select all

text "Your health: [player_points]%" 
with

Code: Select all

text "Your health: [player_points]\%"
Last edited by Uchiha Echinox on Tue Mar 24, 2015 4:17 pm, edited 2 times in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Problem with health points

#3 Post by Alex »

When you increasing health points somewhere in your script you need to do it like

Code: Select all

$ player_points = min(player_max, player_points + some_health_increasing)
to not let the value of player_points be greater then player_max.

https://docs.python.org/2/library/functions.html#max

AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

Re: Problem with health points

#4 Post by AlexCLD »

Alex wrote:When you increasing health points somewhere in your script you need to do it like

Code: Select all

$ player_points = min(player_max, player_points + some_health_increasing)
to not let the value of player_points be greater then player_max.

https://docs.python.org/2/library/functions.html#max
Now I can continue working without problems. Thanks for your help! :)

User avatar
Taleweaver
Writing Maniac
Posts: 3428
Joined: Tue Nov 11, 2003 8:51 am
Completed: Metropolitan Blues, The Loyal Kinsman, Daemonophilia, The Dreaming, The Thirteenth Year, Adrift, Bionic Heart 2, Secrets of the Wolf, The Photographer
Projects: The Pilgrim's Path, Elspeth's Garden, Secret Adventure Game!
Organization: Tall Tales Productions
Location: Germany
Contact:

Re: Problem with health points

#5 Post by Taleweaver »

Moved to Ren'Py Questions.
Scriptwriter and producer of Metropolitan Blues
Creator of The Loyal Kinsman
Scriptwriter and director of Daemonophilia
Scriptwriter and director of The Dreaming
Scriptwriter of Zenith Chronicles
Scriptwriter and director of The Thirteenth Year
Scriptwriter and director of Romance is Dead
Scriptwriter and producer of Adrift
More about me in my blog
"Adrift - Like Ever17, but without the Deus Ex Machina" - HigurashiKira

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot]