Text issue.

Okay, so in python if you ran;


it would print;


And if you ran;

foobar = 'One

That would also print the same thing.
Similarly, in Blender, if you ran;

own.text = 'One

it would display;


But if you run

foobar = 'One
own.text = foobar

it displays


I can’t figure out why this happens. I know I could make a system that - using a monospaced font - every so-many characters went down a line, but, a) What if I don’t happen to be using a monospaced font and, b) I’m too lazy.

Any help is appreciated.

seems to work fine for me. But I dont know what could be wrong on your side

Also tried this

import bge
from bge import logic
from bge import events

def text(cont):
    own = cont.owner
    foobar = 'One
    own["Text"] = foobar

Both outputs resulted as:

Not sure what the problem is. Can you post the script?

Okay, i’ve isolated the problem a bit more.

Let me explain a bit further - I’m making a system wherein once the player passes a certain point, a text box shows up, saying something.
The way i’m doing this is to make invisible ‘activator’ objects. These objects have two game properties, one that’s the exact same for all of them - called ‘activator’ and set to ‘0’, used for collision detection with the character - and one that’s called “message”. Essentially, when the player touches one of these, it gets the value of ‘message’ (using .hitObject) and displays it.

It seems as if whenever I get a value from a game prop, as opposed to a normal variable or plain string,
dosn’t work.

Have you tried adding str() to the message.bodies variable?
example: str(message.bodies[0])

Yeah, I tried it, with no luck.
Also, I’m not actually sending a message, there’s no ‘.body’. “message” is just the name of the game prop on the invisible activator object thingy that is assigned to a string of whatever I want the text-box to say.

Is there any other way of storing strings, than, you know, strings? because then maybe I could change it to that, then back…

Could you post a blend with this working?I want to study it.

The "
" notation is a Python notation (also used in Java and other languages). When you enter strings into the GUI "
" will be interpreted as two character as it does not use this notation.

If you really want to use this character combination as <cr> you need to convert the string with Python. I do not have the exact code here, but a simple string replacement should do the trick.

EDIT: I did some tests. It seems the GUI uses the
notation. But when entered as property value the
interpretation does not take place.

The best bet is to copy the property value with Python. I guess it can even be the same container.


owner[propertyName] = owner[propertyName].replace("\