Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Dialog: Color tag issue  (Read 1989 times)

0 Members and 1 Guest are viewing this topic.
Dialog: Color tag issue
« on: November 08, 2008, 12:00:01 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
http://rapidshare.com/files/161783646/Dialog_box.gmk.html
Well just coded about 10% of a RPG Dialog box, but well I got a color tag issue, it works but it'll change ALL dialog to that color and not just a word>< it also shows the the keys that trigger the color change.

Well hope someone can help.

Screenshots:
Logged

D-Pad

A.K.A. Gyrowolf
Re: Dialog: Color tag issue
« Reply #1 on: November 09, 2008, 06:15:13 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 147
Don't you know about globalvar, man?! Man's best friend...

Edit: Nevermind I see... Hang on a couple...

Edit #2: Yeah... Can't get it working. Sorry... I can post my dialog box to show you how I did it, if you'd like...

Edit #3: Ain't workin'. The best way to check for tags is by drawing one letter at a time, instead of the whole string_copy. Try drawing string_char_at()...
« Last Edit: November 09, 2008, 07:48:41 am by D-Pad »
Logged
Re: Dialog: Color tag issue
« Reply #2 on: November 09, 2008, 05:02:18 pm »
  • The Dark Lord is here...
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 29
I can't download it ._., but I'll lend you a hand. Firstly, the string you draw on screen must be cleared of special characters, but (assuming you draw the string in a while) the string you check on the while must be the uncleared one, so that you can find special characters. When you find one, just set the color to the one you want to change to and skip the part that draws the character. That's the theory, I can't help you further as long as I don't see the code.
Logged
Darth RPG - Feel Dark Side temptation

  • The Legend of Cerda Website

Antidote

>.>
Re: Dialog: Color tag issue
« Reply #3 on: November 13, 2008, 01:50:26 am »
  • In all seriousness who's serious?
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1485
My draw_text_ascii* scripts have this ability, why don't you look at the example and see if you can figure it out there?

While they're rough around the edges and noobish they should be a good starting point for you.

EDIT:
Went to dl your source but then I realized that you used rapid share which is a big no no where I'm at currently. Can I ask you to use a different host? such as willhostforfood.com
« Last Edit: November 13, 2008, 01:54:44 am by Antidote »
Logged
  • Axiomatic Data Laboratories
Re: Dialog: Color tag issue
« Reply #4 on: November 25, 2008, 07:26:59 am »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Don't you know about globalvar, man?! Man's best friend...

Edit: Nevermind I see... Hang on a couple...

Edit #2: Yeah... Can't get it working. Sorry... I can post my dialog box to show you how I did it, if you'd like...

Edit #3: Ain't workin'. The best way to check for tags is by drawing one letter at a time, instead of the whole string_copy. Try drawing string_char_at()...
That would help me out a lot! I mean coding a dialog system is easy, but get anything like color tags, and advanced message stuff, then it becomes extremely difficult><
Logged

D-Pad

A.K.A. Gyrowolf
Re: Dialog: Color tag issue
« Reply #5 on: November 27, 2008, 05:33:04 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 147
Note: The code below is part of a bigger code. I'm just posting it to give you an idea of how I simulate the type-writer style dialog box. It works in my game, but may NOT work if copy-pasted.

Code: [Select]
//===============================================================
// Window Text
// --------------------------------------------------------------
// Draws a string on the screen.
// ==============================================================

txx = argument0;    //Text x position;
txy = argument1;    //Text y position;
tsp = argument2;    //Text speed. 0-1, -1 to have text appear at once;
tst = argument3;    //Text string;

//Make temporary variables.
var oldcol,oldalp,pos,strl,n;       //Old color, Old font, position, string length;

strl = string_length(tst);  //Store the text's length.
pos =1;                    //Position variable.
charpartx = 1;              //Additional space between the letters.
charparty = 1;              //Additional space between the lines.

// charpartx/y variables are multiplied by the current character's
// (letter's) width/height.

// --------------------------------------------------------------
// Drawing the text ->
//-> To draw the text we start a loop. In the loop, we check the
//   character at the current pos(ition) and draw it, refreshing
//   the screen and sleeping as we go.
// --------------------------------------------------------------
io_clear(); //Clear keyboard and mouse status.

n = 1;
while (n == 1)
{
    for (i=0;i<strl;i+=1)
    {
        //If a color tag is found:
        if (string_char_at(tst,pos) == '[' && string_char_at(tst,pos-1) != '\')
        {
            draw_set_color(c_aqua);
            pos+=1;
        }
        if (string_char_at(tst,pos) == ']' && string_char_at(tst,pos-1) != '\')
        {
            draw_set_color(c_white);
            pos+=1;
        }
        //If a new line tag is found...
        if (string_char_at(tst,pos) == '#' && string_char_at(tst,pos-1)!= '\')
        {
            txx = argument0;                                        //->Jump back to the beginning of the line.
            txy+=string_height(string_char_at(tst,pos))*charparty;  //Go down to a new line.
            pos+=1;                                                 //Move forward one position without
        }                                                           //drawing the symbol.
        //If a "/" symbol is found...
        if (string_char_at(tst,pos) == '\')
        {
            txx +=1;
        }
        draw_text(txx,txy,string_char_at(tst,pos));                 //Draw the character found at pos.
        txx+=string_width(string_char_at(tst,pos))*charpartx;       //Move over a bit for the next char.
        screen_refresh();                                           //Refresh the screen.
        if (tsp > 0)                                                //If text speed is greater than 0
            sleep(40*tsp);                                          //sleep for a bit.
        pos += 1;                                                   //Add one to the position.
       
        //-------------------------------------------------------
        //If the end of the string is reached.
        //-------------------------------------------------------
        if (pos >= strl)
        {
            io_handle();    //Update keyboard/mouse status.
       
            screen_refresh();                               //Refresh the screen.
           
            if (keyboard_check(ord('Z'))) {n = 0; break;}   //Check for Z key, and break if pressed.
            if (keyboard_check(vk_escape)){n = 0; break;}   //Check for escape key.
           
            if (!keyboard_check(ord('Z'))) n=1;             //Else, keep drawing the text.
        }
    }
}

What it's basically doing, is drawing one letter at a time, instead of drawing a copy of the whole string (as you were doing). Because of this, I can control each letter in the string as I want. I.E, I can change each letter's size, color, font, etc.

Once it reaches the end of the string (pos(ition) > string_length), it waits until the user presses a key, and then breaks out of the loop.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.046 seconds with 50 queries.