really ?? No vectors as properties?

Last night, I discovered that there is no type, vector for properties, and that the text object could not re-cast a vector to a string… can some one fix this?

I worked around it by setting the variable with python, but this function would be very nice…

I don’t think it needs to be fixed. The game object properties are very generic and easy to use - a vector’s something that’s pretty complex. Even with it, it would be pretty useless unless you patched the property sensor and actuator to deal specially with them (exposing their magnitude, individual X, Y, and Z elements, etc).

But wait, what do you mean the text object couldn’t re-cast a vector into a string? Did you try:


textobj.text = str(vector)

it says negitive 1, print shows the vector, so python, the vector is fine,

I use
object[“Property”] = some vector

then in another object I can use
always --------copy-----------property

to feed the property to another item,

this makes modular code pieces that can be used over and over, and can be accessed like a node, but I can’t do a vector :frowning:

I don’t think you can store Python-defined variable types in game properties - only the built-in variable types (float, integer, string, etc) can be used. I’d also doubt if you can swap variables in Python (i.e. set VariableA to a string and VariableB to an integer, and then swap their data with Python so that VariableA is an integer and VariableB is a string).

You can store any Python object on an object’s game properties. However, Python types aside from fundamental string, bool, int and float are not interfaceable with the Logic bricks. So, whilst you could set a class instance to a predefined property in the UI, it would not work with logic bricks, even if you defined special access behaviour.

Hrm, so what would it take to add vectors to the logic system?

I know they are working on using X as a force number etc

External properties (as provided and used by the GUI) are restricted to the primitive data types as listed in the GUI.
Internal properties (as set via Python) can be any data type. Please keep in mind, if it is not a primitive one, the property stores the reference not the value.

This has following effects:
A) you can store and retrieve vectors (by reference) to/from a property
B) you can’t use this property in the GUI (e.g. property sensor) as it is not supported there. This includes the “Text” property of FontObjects.

ahh so I can pass and use the variable, just not see it outside of python…
how quantum…

I just use a text in game alot of the time so I can debug by switching who it is copying a property from
o well, I guess I will have to have the console up, I wish I could assign the console to a face texture for a debug hud in game…

for display you can still convert the object to string


textobject["Text"] = str( myVector )

as this does not always look nice you can write your own converter:


def test(cont):
    myVector = cont.owner.worldPosition
    cont.owner.text = convertToDisplayString( myVector )
    
    
def convertToDisplayString(vector):
   display = "("
   for i in range( len( vector )):
       if i>0:
           display += ", "
       display += "{:> 5.3g}".format(vector[i])
   display += ")"
   return display