Page 1 of 1

Text box

Posted: Sun Apr 20, 2008 10:23 pm
by Danimita92
Well, I ask this for a user in the Spanish RF community. He wants to add a text box into a game. Like for example, in mid-game, he hits the ENTER key, opening a text box in which he types a word, activating a script's order or activating a trigger. Is it possible?

Re: Text box

Posted: Mon Apr 21, 2008 5:20 pm
by Jay
It's definitely possible.
First have your text box layout as a bitmap file. Include the bitmap file through a FlipBook entity. Then you can display it. To know how to do so, read my tutorial. (It would take a bit long for me to explain everything again and again.). In the tutorial, i cover how to display an level-up-screen. Displaying a TextBox would be even easier. Be sure to use a seperate low-level order for the TextBox. This order will then be set with self.think=... as the thinkorder in low level (it is not possible to do thinghs like text boxes or dialog boxes in high level)

In my demo, i also use a kind of DialogBox-System when you want to go to sleep or buy thinghs.

With your text box, you could have a buffer in which you write all the input, for example

BUFFER []

and then in the low level order of the TextBox you must make an input part for EVERY letter in the alphabet - so that every one of them can be taken as input. Then you just append it to the buffer with

BUFFER = StringCopy(BUFFER) # INPUTKEY; //INPUTKEY

The KeyboardScanCodes cheat sheet is a good ressource for doing something like this. Print it and lay it next to your keyboard you will use it a lot. This way you always know which letter is which keyboard code on the keyboard when testing for the input keys.

Backspace is also possible:
BUFFER = LeftCopy(BUFFER,GetStringLenght(BUFFER)-1);

Displaying the text works with the DrawTextCommand(...).

I hope you understand better when you have read my RPG tutorial.