[Python]GridLock system

Hi, its been a while I didnt played in blender so I went back trying to do some stuff and I went on on making a gridLock system in python… but I had some problems:

##### Mico27's gridLock system ####
controller = GameLogic.getCurrentController()
##Mouse sensor##
mouseOverStage = controller.getSensor("Mouse_Over_Stage")
Pos = mouseOverStage.getHitPosition()
x,y,z = Pos
##Rounding the x and y coordinates##
x = int(x)
y = int(y)
##Rounding z to 4 digits after dot##
z = (((float(int(z*10000+0.1)))/10000))

##get the terrain's cursor##
scene = GameLogic.getCurrentScene()
objList = scene.getObjectList()
PlaneCursor = objList["OBPlaneCursor"]
##set it to the Rounded coordinate of the mouse's cursor##
PlaneCursor.setPosition([ x, y, (z+0.1)])
##Check for flat terrain##
z %= 0.1
print z
##>>##in the next line, (z==0.1) doesnt work even when it shows 0.1 in the console##<<##
if (z == 0) or (z == 0.1):
    ##Flat terrain so put green cursor##
    PlaneCursorColor = controller.getActuator("replace_PlaneCursor")
    PlaneCursorColor.setMesh("PlaneCursorGreen")
    GameLogic.addActiveActuator(PlaneCursorColor, True) 
    
else:
    ##sloppy terrain so put red cursor##
    PlaneCursorColor = controller.getActuator("replace_PlaneCursor")
    PlaneCursorColor.setMesh("PlaneCursorRed")
    GameLogic.addActiveActuator(PlaneCursorColor, True) 

the problem is explainned in the code.

thanks in advance for helping.

Hey Welcome back Mico27.

I loved the look of your Kirby game. Happy to have you back and can’t wait to see what you’re working on now! :smiley:

What happens if you try

if 0 <= z <= 0.1:

that would result as if any position would be true because of (z%=0.1)
the problem is that when I print in the console the z pos after (z%=0.1) and that it shows “0.1” it doesnt return true to (z == 0.1) in my condition statement…

So I’m kinda clueless right now :confused: