I need to set a python tag for a float number, called dst. I need to do this so I can tag dst with it’s respective object. I just want to tag the name, but I can’t, you can’t make tags to float nums. Is there a workaround for this?
I’m not sure I understand the problem. You can pass any Python object to setPythonTag, including floating-point numbers:
>>> from panda3d.core import NodePath >>> path = NodePath('node') >>> path.setPythonTag('some_float', 123.4) >>> print path.getPythonTag('some_float') 123.4
My interpretation is that robberguy wants to attach a tag to a float.
If I’m correct, then I’m honestly not sure of what might be a good way to go about it; a dictionary would presumably associate the value (which might change, depending on his purposes) with the desired tag, and floating-point imprecision might be an issue.
He might get away with using a dictionary that associates the string “dst” with a value, converting between string and variable on the fly (presumably using “exec” to convert from string to variable; I forget whether one can easily get the name of an object as a string).
Of course, if there’s only one of “dst”, then he could surely simply create a new variable - “dst-tag”, for example - in which to store the desired data.