It prints true or false.I am trying to get it to switch states.Calling mouse mace is intentional because i have more than one python code that is similar.Because i copy and paste then modify them.That was the only way I know of to get it to work.
It prints true or false.I am trying to get it to switch states.
And where is the state you need switched?
act = controller.actuators["storp"]
group = act.mask
act.mask = 2
This one? You can put it in the same if statement as the above. If it doesn’t work then you need to debug these lines alone. Have you activated the actuator?
controller.activate(act)
I’m not an expert on SCA nor do I wish to be but I bet someone can help you with it. Perhaps you should at least verify the state after you try to change it and it doesn’t apparently change.
Calling mouse mace is intentional because i have more than one python code that is similar.Because i copy and paste then modify them.That was the only way I know of to get it to work.
How each script refers to stuff is only relevant to that text block at the max. But they are also relevant to a single function at best if you don’t pass them. The SCA names are only relevant to the python controller they link to. You shouldn’t really just go renaming everything to something that can’t be understood just to be safe. Makes it hard for other people to see what you are doing to help you.
Indeed you need to activate the actuator to make it run.
You do not need a separate Python controller. A simple AND controller will be sufficient (and faster).
BTW:
bge.render.showMouse(1)
should not be part of that code.
A) because you need that just once
B) it has nothing to do with your code.
Better use the configuration switch at the properties panel or if you need it dynamically execute a Python controller that switches the cursor and only the cursor.
Hint: There is no need to define the attributes controller and scene twice ;).
Still not indented properly and with the names like that and double defining things. It’s a nightmare reading that code.
import bge
controller = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
mouse = controller.sensors["Mouse"] #proper name
mouseOver = controller.sensors["MouseOver"] #proper name
hitpos = mouseover.hitPosition #proper name, this line does nothing useful
if mouse.positive and mouseover.positive: #why do you check for both
storp = controller.actuators["storp"] #what is storp, one of your renames again, lets call it that anyway
#group = storp.mask #this line does nothing useful
storp.mask = 2 #proper name, indentation
controller.activate(storp) #activate the actuator AFTER you set the parameters
print ("Mouse is moving and over something")
controller.owner.color = [1.0, 0.0,0.0,1.0]
else:
print ("No mouse movement or no object under mouse")
controller.owner.color = [0.0, 1.0,0.0,1.0]
Because looks like you aren’t setting the operation type at all and chances are you don’t understand how to properly express bundle of groups in bits either although for 2 it should matter.
No i did not see that Kheetor.I found some code in the search and modified it by placing it together with some other code i found on Tutorials for Blender 3D and the Blender Blender 3D Game Engine websight.That is the websight i was telling other people about.