I know I seen this somewhere before on this forum but I can't find it. I need to know how you can calculate the min and the max of variables. I have a variables that can go from 0 to 100. I need to find that ,in or max of the variables and stop it if it goes past the min or max.
example:
Mom Favorite = 98
down the line you add the varibles
$ mom_favorite += 5
Max and minimum on varibles
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.
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.
- DragonKnight
- Regular
- Posts: 51
- Joined: Sun Nov 12, 2017 10:16 am
- Projects: Taboo Hearts
- Contact:
Max and minimum on varibles
Currently working on Taboo Hearts
Currently working on Forbidden
Currently working on Forbidden
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Max and minimum on varibles
One way to do that:
Other way is to make some kind of BoundedValue class and use it. It is pretty simple, but you will need to know some Python to make it.
Code: Select all
init python:
def clamp(n, smallest, largest):
return max(smallest, min(n, largest))
# Later, after each variable change:
$ mom_favorite += 5
$ mom_favorite = clamp(mom_favorite, 0, 100)
< < insert Rick Cook quote here > >
- DragonKnight
- Regular
- Posts: 51
- Joined: Sun Nov 12, 2017 10:16 am
- Projects: Taboo Hearts
- Contact:
Re: Max and minimum on varibles
Thank you!!!!!!!!!
Currently working on Taboo Hearts
Currently working on Forbidden
Currently working on Forbidden
Who is online
Users browsing this forum: Ahrefs [Bot]