Search code examples
pythonrenpy

Increasing a variable by either .5 or 1, depending on current value


I'm trying to make a manual increase of a value (via a button), and increase to the nearest whole number, before continuing to increase by one for each click.

So, if the variable is var = 1 increase by 1 to 2, but if var = 1.5 increase to 2

This is done in Ren'py, but I don't care about that, as long as the solution is in Python code.

Currently, the increase code I have is this: SetVariable(stats[1]+"_dom",getattr(store,stats[1]+"_dom")+1) (Ren'py specific)

I'm sure there is a simple way of doing this in Python, but I'm not 100% sure what to search for.


Solution

  • Add 1, then round down. (int() or math.floor())