Writing text & selecting objects in game

Hi, i want to design a scene with this function:

  • When I click on an specific object and a text box must appear in some place in the window.
  • In this box I can write a text and when I pulse enter tha text will be save in a file.

The problems are:

  • ¿How can I know what object is selected? I’m using ray-sensor but this returns an object for which I can’t obtain his name or property.

  • ¿There is a method wich I can write a text in box without need to put a sensor for each ‘key’ of keyboard?

Sorry for my english if it’s no correct, it’s not my nature language.

Thx and greetings.

in python, once you’ve got a game object you can just get its properties

erm

import GameLogic
cont = GameLogic.getCurrentController()
rs = cont.getSensor("ray")
print rs.getHitObject().bleh # print bleh property of the object sensed by ray sensor 

setup an object to display text [see https://blenderartists.org/forum/viewtopic.php?p=365972#365972 if you don’t know how to do that]

on that object add a keyboard sensor
set to “all keys”
set “Target” to Text
[this will put what you type in in the Text property, and backspace works… so you can type in stuff. though, it is of note that many characters do not work as they should. All letters and numbers however ought to work fine]

it’s not really a problem, though we don’t start questions with '¿'s…

Thanks for responding.

About this:

set to “all keys”
set “Target” to Text
[this will put what you type in in the Text property, and backspace works… so you can type in stuff. though, it is of note that many characters do not work as they should. All letters and numbers however ought to work fine]

I tried it before I wrote this post but it did not work. In The Official Blender Gamekit is written this: “The Keyboard sensor can be used for simple text input. To do so enter the property that should hold the typed text into the Target field. The input will be active as long the property in LogToggle is TRUE.”

The problem is that I don’t understand well the mechanism of LogToggle so I don’t know if it is determining so that it works. Actually I have a string property called “Text” (no quotes) and a keyboard sensor with option “allkeys” selected and Target=Text.

Using script I confirm that when any key is pressed the sensor it shoots but is nothing in screen.

PD: the object used to display text works in other cases, only it doesn’ show text in “allkeys” case.

oh, I had forgotten about logToggle

create a bool property, set it to true, and put its name in the LogToggle spot

when you don’t want the user to be able to type in there set that proeperty to false