I'm having a python problem...

This is really starting to get under my skin. I have a property assigned the value of a message body(in python of course) like this:

message = cont.getSensor("sensor1")
body = message.getBodies()[0]

I assume this is because messages and their respective bodies are only temporary variables in blender, but how the heck can I copy the freakin value?! :< (So as to “cement” it)

Oh, and by the way, here is the error message it spits out to the console window:

Traceback (most recent call last):
  File "Text", line 4, in ?
TypeError: unsubscriptable object

I realize that when you make a variable like that it makes a pointer to the value, and not a copy, but that’s what I need; to copy the value. This spits out that error message at 10x the speed of light, and so if there was a problem anywhere ELSE, I would NEVER see it, because it would get “washed away” by the error messages.
I’ve looked everywhere, and I couldn’t find an answer…

no idea if this is the a good way to do it.

 if c.getSensor("msg").isPositive():
      val = c.getSensor("msg").getBodies()[0]

hope this helps. :slight_smile:

this works if you tie a message sensor to this python script

if sen.getBodies()!=None:

you can also store them in an array if more that one the use for loop to retrieve them(that should eliminate your error)

for x in val:
if 2&lt;=i:
   print val[2]

Never mind, I fixed it by using a global variable.