-1

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.

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33

2 Answers2

1

You could just do variable = int(variable + 1)

jtagle
  • 302
  • 1
  • 8
1

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

John Gordon
  • 29,573
  • 7
  • 33
  • 58