It works... but how?

Using 2.53 I have a single object in a scene. It’s a text object that I’ve appended from somewhere. So I’m in the 3d view looking at a bold arial ampersand.

I’ve given this object a Timer property, an Always sensor and a python script. Nothing else.

Here’s the python script:

own = GameLogic.getCurrentController().owner
myTime = own[“prop”]
own[“Text”] = myTime

I hit P and it works. I’ve got an onscreen timer. But how? I haven’t given it a property named “Text”. It needs line 3 to work and it needs “Text” within the square brackets. What gives?


TimerTest.blend (362 KB)

I do not understand you.
You have a problem that your .blend is correct?
Or is it that you do not understand how it works?

Maybe I misunderstand you, but here is my answer (or better your answer ;))

this one:

Maybe text objects have a [“Text”] property by default.

…but why did you think to try that if you didn’t think it would work?

Yo Rob, I was thinking something like that. But then I’m thinking that to Blender it’s just an ordinary plane with an image of text as a texture.

And yeah, since it seems that nothing but “Text” allows the timer to display at runtime how did I happen to type the only thing that does? I don’t remember that “Text” was automatically assigned anywhere in the GUI or that it can be contained anywhere in the object. If I retype “Text” as “text” the program runs with no reported errors but doesn’t display the timer.

Hi, Monster, maybe you can see now why I’m confused.

not really:
own[“Text”] = something
adds a property Text to the object referenced by own. There is no need to define the property at the gui (except you want to enable the debug button).

By the way, you can call your timer property Text than you can get rid of the script.

Yo, Monster. You are right. I removed the script and the program ran but without the clock. I then renamed “prop” to “Text” in the properties panel and the program displayed the clock, no script at all required.

So it seems that it must be something that was coded into the BGE. Maybe as a convenience for the programmers testing performance of their code.

Yes, its coded into the BGE. If you have the ‘TEXT’ button set on the plane in Edit mode, and you have a Text property in the object, the plane will display the text in the ‘Text’ variable (also assuming the plane with the @ on it has a proper text image on it).