'module' object has no attribute 'object'?

Hi guys, i need some help with debugging my python script. I’m trying to map keyboard key 1=pinkseed, 2=orangeseed, 3=blueseed

I am able to run the pinkseed without any problems. However, i can’t do it for the other 2 seeds. My python command prompt shows me the following message,

"Python script error from controller “script#CONTR#1:
Traceback <most recent call last>”
File “showpointer”, line 39, in <module>
AttributeError: ‘module’ object has no attribute ‘object’

Can somebody help?

Attachments

rosegarden.blend (734 KB)

I don’t have time to look at your blend, but generally when it says this it is because you forget an inherent class. I.E. Let’s say object has the property “Health”, and your object’s name is “enemy”.

doing this will not work


Health = Health - 1

but doing this will work


enemy.Health = enemy.Health - 1

Check for something like that or similar, especially the line of the error!

Just had a look at the .blend and I changed the & symbols in those lines to the word and. It works, but the camera also calls that script and brings up another error so you might want to sort out that link too.

Good luck.

so instead of using & i should use “and”?
Hmm, ok will try it out. Thanks!

The way I understand it, & is a logical operator like +, -, *, / where for example
11001100 & 11000011 = 11000000 in binary.

or 5 & 3 = 1 (00000101 & 00000011 = 00000001)

For the boolean comparison use the words “and”, “or”, “not”

Can i check with you guys, how should i go about doing it if i want, when object A is selected, a mouse click on object B will increase its property value by 1.
When object B’s property value = 3, it will replace mesh to object C?

Its the first part that i’m confused about, how do you increase B’s property value (which i set as Int) by 1 each time you click it. There will be multiple object Bs on the plane, and i only want the particular object B that is clicked to increase its value. Is this possible?

Sorry if i’m not very clear, tried to upload my .blend but its too big.

One thing that I’ve thought about that would (if it would work) be the sulotion for your problem would be to get properties through the get.Owner(), or something similar, but I don’t know if it works. In my case I want it because it would shorten a script that I’m working with ten times.

Any idea on how to do it, if it works or any other way you might be able to do it? Anyone?

Edit: I’m working on a .blend, I’ll show it soon, but it’s not the getOwner() that I’ve used…

PS. Saw that you used some parts of the mouse theory script.

Here’s a way to do what you wanted with only logic. (except for a 2 line script to show the mouse)
Note: the replace mesh does as it says and only swaps mesh. It’s still the same object, which means that you should only do things to the original object.

Attachments

SeparateSameObjects.blend (133 KB)

Hi, i used radar instead. But the detection is very inaccurate because my watering can object is at a higher level on the z-axis than the seeds on the ground.

The issue im facing now is that i cant seem to get the seed object to add a value to its property after detecting the watering can object. This is frustrating