Page 1 of 1

Talk to Characters

PostPosted: Sat Dec 08, 2007 6:35 pm
by Super Pieman
I am making a zelda game, it is pretty much a remake of the minish cap, and i can't get the textboxes to work. I have tried several codes but nothing is working. Can someone start me off. I will give you 2 points if you can help. Ps. When talking most people say multiple boxes of words, for example they say "Hello Link, how are you today" you press enter "have you visited the BAKERY yet?" you press enter again, then the text box closes.

Re: Talk to Characters

PostPosted: Sat Dec 08, 2007 6:58 pm
by Azou
We'vegot the same problem! :( Maybe a noble gentleman will help us! :D

Re: Talk to Characters

PostPosted: Sun Dec 09, 2007 5:44 am
by pyrometal
Well here's a structure you may want to try using to code NPCs on a KeyDown Event located in the text actor:

Code: Select all
if (distance(player.x, player.y, NPC.x, NPC.y) <= 20)  //Event only occurs when player is close enough to NPC (Defines a 20 px radius).
{

    EventDisable("player", EVENTALL);  //Disable player controls
    transp = 0;  //Set the Messages to be visible

    switch(Dialogue_Position)  //Keeps the position in the dialogue
    {
        case 1: sprintf(text,"Hello Link, how are you today?",text); //Change the message
                Dialogue_Position++;  //Increment Dialogue's position by 1
                break;  //Ignore the rest of "case" labels

        case 2: sprintf(text,"Have you visited the BAKERY yet?",text);  //Same as Case 1 (You can have as many as you wish)
                Dialogue_Position++;
                break;

        case 3: sprintf(text," ",text);
                transp = 1;  //Make the messages invisible.
                EventEnable("player", EVENTALL);  //Enable player controls
                Dialogue_Position = 0;  //Reset Dialogue Position to 0 in order to be able to go through the dialogue another time
                break;
    }
}


Note that it would be in your best interest to set your NPCs in a manner to avoid convergence of the proximity radii in order to avoid unexpected (and funky) behavior when initiating the preset conversations. Also try keeping the scripts as organized as possible so you can easily modify your text.

You will probably need to use the "\n" control character in your text formatting in order to split your text onto other lines (Like using ENTER).

Example:

Code: Select all
sprintf(text,"This example text string\nis spread over two lines!!!",text);


Hopefully this helps you in your game's conception. If you have any other questions about this, ask!

Well, that's all for now!

-- Pyrometal --

Re: Talk to Characters

PostPosted: Sun Dec 09, 2007 1:55 pm
by Super Pieman
When i enter the script there are no error messages but for some reason the cases arent working

Re: Talk to Characters

PostPosted: Sun Dec 09, 2007 3:29 pm
by pyrometal
Sorry, I made a stupid mistake. The cases are supposed to be numbered 0,1,2... instead of 1,2,3...

Here's a working example:

Dialogue Script.zip
(206.67 KiB) Downloaded 167 times


Sorry about that, I should have noticed before sending. The code should work now.

-- Pyrometal --

Re: Talk to Characters

PostPosted: Sun Dec 09, 2007 4:47 pm
by Spidy