How to use python tags?

So I used my python tag like this:

self.zombie[x].setPythonTag(HP, 100)

and so I need to do this for each zombie, and they each need and HP. So when I executed the script it gave me:

NameError: global name ‘HP’ is not defined

What the heck? How do I use python tags like I want to?

Stop swearing and learn Python basics.

setPythonTag is a Python function like every other Python function. It accepts parameters, which can be literals or variables/constants. You pass HP as the first parameter, which is obviously a variable or constant. And obviously you have missed to define this variable or constant before calling setPythonTag.

HP = "hitpoints"
self.zombie[x].setPythonTag(HP, 100)

Or simply pass a literal:

self.zombie[x].setPythonTag("HP", 100)

Ok, thanks a lot, I will try this when I have time.

Just one thing…

Is there a strict rule on swearing in these forums, or are you just joking? Or are maybe you are angry (don’t know why)?

No, there is no strict rule about swearing. At least I am not aware of one. It’s a matter of common courtesy.

Have you been able to fix your issue? If not using a literal then global variables are a good idea, but you need a decent grip on Python namespaces in oder to ensure that your globals are visible everywhere you need them.

It works fine, thank you very much for your help.