Tutorials - Blender Game Engine
Allowing the User to Input Textby blendenzo, with special thanks to Social and z3r0_d
Due to bugs with the Firefox Blender plugin, it is recommended that you view this tutorial using Internet Explorer with the Blender 2.25 web plugin.
Example files (zipped package): Not ready yet...
Version Info: Blend made with 2.42a. Compatible with all versions of the BGE.
When the boolean property listed in "LogToggle" has a value of "True" the user's keystrokes are recorded to the "Target" property. In the example above, as long as prop is True, whatever the user types will be recorded to Text. Since Text is the display value of the bitmap text object, the user's input will be displayed directly to the screen. Social demonstrates this basic function in text_input.blend (126 kb). The plugin below shows the in-game results.
Firefox users: Due to an apparent bug with the Firefox plugin, you must navigate away from this page while the plugin is showing, then use your browser's back button to return here before the text will display properly. This applies to all plugins on this page. password_input.blend (130 kb) and take a look. In this example I've used three bitmap text objects. The first instructs the user to "Enter Password." The second text object receives and displays the user's input. The third will display "Password Correct" if the user enters the correct password. Take a look at the middle text object. In its logic you will find that I've added a property with the password value.
Now look at the Logic Bricks.
When the user presses the carriage return key (Enter), the value of Text is tested to see if it is the same as password. If it is, the message "Password Correct" is displayed. Notice that the expression controller "TextIsPass" is connected between two text objects. The plugin below demonstrates this setup in-game. Use the [Left Ctrl] key to confirm your password, as the plugin does not recognize the [Enter] key.
Now go to the Blender Text Editor and make a new file named "Mask.py". Here is the script (you can paste it into the Blender Text Editor using [Ctrl+Shift+V]):
Back to the tutorials index...
Website design by Tony "blendenzo" DiRienzo. All content © Copyright Tony DiRienzo unless otherwise noted.