There isn't a built-in solution afaik, but you can define a python function for that yourself pretty simply. Just as a barebones structure that you can build off of (not guaranteeing that it will work as is, I haven't tested it in Renpy and sometimes Renpy doesn't do exactly what I expect it to with python):
Code: Select all
init python:
def change_stat(stat, amount):
stat += amount
if stat > 100:
stat = 100
elif stat < 0:
stat = 0
return stat
#script example
$ energy = 0
$ energy = change_stat(energy, 150)
$ energy = change_stat(energy, -150)
If you have a lot of variables with different max/mins, you could structure a whole class and use methods, etc., but depending on the complexity of your game and your level of comfort with python, you could just go for something simpler.
You could also look to the DSE:
http://www.renpy.org/wiki/renpy/DSE
Some of the DSE code is outdated, but it's still a useful framework if it fits what you're trying to do. It also has a stat system in place that could be a good reference if you're trying to build your own.