Page 1 of 1

False INPUT text :)

PostPosted: Fri May 28, 2004 3:59 pm
by ingsan
Example : I would like to write ABCD on Screen. How can I do this ?
Simple :wink: First create 5 Text Actors : Helper, FirstLetter, SecondLetter, ThirdLetter and FourthLetter.

On Helper :

Add Event CREATE ACTOR, add Script and write :
    int KeyDown = 1;
Add Event KEYDOWN (any key), add Script and write :
    KeyDown ++;
On FirstLetter :

Add Event KEYDOWN (any key), add Script and write :
    char * Letter = GetKeyState();
    if ( Letter[KEY_a] == 1 && KeyDown == 2)
    {
    strcpy (FirstLetter.text , "A");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once
    }
    else if ( Letter[Key_b] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "B");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }
    else if ( Letter[Key_c] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "C");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }
    else if ( Letter[Key_d] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "D");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }

What you do on SecondLetter, ThirdLetter or FourthLetter actors is the following :
Just Replace "FirstLetter" in the code above by the corresponding Actor's name e.g SecondLetter Actor > SecondLetter.text in Script.
Replace the following conditional value of integer variable KeyDown for each actor :
For SecondLetter > KeyDown == 3;
For ThirdLetter > KeyDown == 4;
For FourthLetter > KeyDown == 5;

Fine, now test it ! :)