Ryptun
(Ryptun)
February 17, 2014, 11:47am
1
I wanna join some text with object property value. Something like that:
import GameLogic
cont = GameLogic.getCurrentController()
obj = cont.owner
MyProperty = obj["Property"]
seq = ("aaa", MyProperty, "bbb");
MyJoinedText = "".join( seq );
print(MyJoinedText)
…and it’s not working, beacuse can’t read property value
Any ideas how to fix it?
Raco
(Raco)
February 17, 2014, 12:16pm
2
It’s not very clear what you really want. Do you want a string of a list, or do you want to join the strings of items in a list? What are you trying to do actually?
Ryptun
(Ryptun)
February 17, 2014, 12:28pm
3
I just have a simple string text in Property.
Something like obj[“Property”] = MyText_123
After join it should be: aaaMyText_123bbb
Monster
(Monster)
February 17, 2014, 12:30pm
4
a = “aaa”
b = “bbb”
myPropertyValue = obj[“myProperty”]
joined = a + myPropertyValue + b
superflip
(superflip)
February 17, 2014, 12:36pm
5
you could join by just concantenating them in seq and turning MyProperty to a string
seq = “aaa”+ str(own[“MyProperty”])+“bbb”
Edit: Whoops, Monster beat me. i only use the str() because i assumed MyProperty was a number or something
Monster
(Monster)
February 17, 2014, 10:11pm
6
indeed if your property does not contain a string value you should convert it to a string first. Simplest way: str().