How to Limit Properties

So I have an int property that has hundreds of combinations of adding and subtracting. And I need this property to stay above -1.

Is there an easy way to give a property a limit, instead of writing a thousand-line long python script defining all of the different combinations of adding and subtracting to keep it above -1?

And don’t say to make an actuator set the property to zero when it becomes negative. If you do that, it will go negative for a logic tic before setting to zero. I need it to stay above -1 ALWAYS

please help me! I have no idea how to do this

if the property name is “prop”, this p-script should do it


import GameLogic
 
cont = GameLogic.getCurrentController()
own = cont.getOwner()
 
p = own.prop
 
if p<-1: p = -1

WOW I have no Idea why I didn’t think of that!

if I just put that in the last line of my script it will keep It above -1.

I feel so stupid right now. thanks alot though!

Thats OK. Most simple solutions are sometimes very hard to think out :).