str() will not work

hello,
I am trying to set the value of a property actuator. Here is what I have:

mass2.value = str(Tlocal_scale)

So the actuator is named mass2 and I am trying to turn the variable Tlocal_scale into a string. for some reason the blender system console and it gave me nothing. The game property is not being changed at all and I have no idea why. I tried printing the variable to the console and it gave me a value but whenever I would set it as a property it would do nothing.

Please help me :frowning:

-Matthew

What does your variable Tlocal_scale contain (if you do not know print it to console)?

The property actuator changes properties ONLY after activation. This means you need to activate it by any connected controller.

Be aware, the value field of the actuator expects code of the mini language. If you want to set a string value you need to put it into " ":


mass2.value = ' "{}" '.format(str(Tlocal_scale))

Otherwise the actuator interprets it as name of a property:

[table=“width: 500, align: left”]

[th]Value field[/th]
[th]Result[/th]

[th]Type[/th]

name
the value of a  property called name

type of the property value

"name"
name

string

1
1

integer

"1"
1

string

1+2
3

integer

[/table]

I feel so stupid… I forgot to activate the actuator, Thanks. :stuck_out_tongue:

-Matthew