junkfoodjunkie
junkfoodjunkie

Reputation: 3178

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.

Upvotes: -1

Views: 778

Answers (2)

John Gordon
John Gordon

Reputation: 33352

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

Upvotes: 1

jtagle
jtagle

Reputation: 302

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

Upvotes: 1

Related Questions