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: Text Box Woes  (Read 2406 times)

0 Members and 1 Guest are viewing this topic.
Text Box Woes
« on: November 02, 2013, 09:51:19 am »
  • *
  • Reputation: +12/-2
  • Offline Offline
  • Gender: Male
  • Posts: 4849
Decided to program a sprite font text box system that works around GM 8 Lite's limits.  GM8 Lite doesn't let you use the built in sprite_font functions.  Anyway, instead of boring you with details, I'll tell you the system works.

However, I am trying to add an automatic "-" addition when you reach the edge of the box and are currently in a word.  It's not going very well.  I've come close a few times but then screw it all up.

Code: [Select]
//In child object, have a begin step that contains your completeText ie string
if active == true && paused == false
{
completeCharcount = string_length(completeText);
if timer = 0
{
if (currentCharcount <= (completeCharcount))
{
    if string_char_at(completeText,currentCharcount) != " " // && charperline > 0
    {
        //sound_play(sndTextAppear);
        currentWord += string_char_at(completeText,currentCharcount);
            //drawn_text += string_char_at(completeText,currentCharcount);
        charperline -= 1;currentCharcount += 1;
    }
    else if string_char_at(completeText,currentCharcount) == " "
    {
        if wordCharcount <= string_length(currentWord)
        {

            if string_length(currentWord) >= charperline
            {
                //drawn_text += "#";
                if charperline > 0
                {
                    drawn_text += string_char_at(currentWord,wordCharcount);charperline -= 1;
                    wordCharcount += 1;
                    //charperline -= 1;
                }
                else
                {
                    drawn_text += "-";
                    charperline = 24;
                }
               
               
                sound_play(sndTextAppear);
            }
            else if  string_length(currentWord) < charperline
            {
               
                drawn_text += string_char_at(currentWord,wordCharcount);
                wordCharcount += 1;
                sound_play(sndTextAppear);
            }
        }
        else if wordCharcount > string_length(currentWord)
        {
            charperline -= wordCharcount;
            drawn_text += " ";
            currentCharcount += 1;
            wordCharcount = 1;
            //charperline -= 1;
            currentWord = "";
            sound_play(sndTextAppear);
        }
     
    }
   
    if string_length(drawn_text) >= 71
    {
        drawn_text = string_copy(drawn_text,24,48);
    }
}
else
{
    finished = true;
}
timer = 30;
}
else
{
    timer -= response;
}
}

Also tried this:
Code: [Select]
    if string_char_at(completeText,currentCharcount) != "^"  && frac(currentCharcount/24) != 0
    {
        sound_play(sndTextAppear);
        //currentWord += string_char_at(completeText,currentCharcount);
        drawn_text += string_char_at(completeText,currentCharcount);
       
        currentCharcount += 1;
    }
    else if frac(currentCharcount/24) == 0
    {
        if string_char_at(completeText,currentCharcount-1) != " " //&& string_char_at(completeText,currentCharcount-1) != " "
        {
            sound_play(sndTextAppear);
             drawn_text += "-";
        }
        else if string_char_at(completeText,currentCharcount) == " " || string_char_at(completeText,currentCharcount) == "-"
        {
            sound_play(sndTextAppear);
            //currentWord += string_char_at(completeText,currentCharcount);
            drawn_text += string_char_at(completeText,currentCharcount);
       
            currentCharcount += 1;
        }
    }
This one just !@#$% stops at the 24th character.  Doesnt even make !@#$% sense why it would just stop.  Been at this for 2 hours at this point, so I am a little steamed.


I reused the parsing code of my rpg textbox engine from a couple years ago.  You won't be able to directly use this as that code is in a parent object, while the child object holds the actual text. 

I uploaded a couple pictures of different results I have gotten.  This system is only to allow 24 characters per line, which works fine.  What isn't working is that if you are currently in a word and near the end, at the 24th character on the line, add a "-" to the drawn_text.  The system is adding it at weird spots that I know is my fault but I can't find it.

The code I posted is all that deals with getting the drawn text string.  You don't need anything else as the rest of the code is just activating the box and drawing the box and text which works fine.  If you think you can figure it out, let me know.  The previous system just added a "#" which is a newline in Game Maker when you reached a word that was too big.  That won't work with hard-coded spritefont :/

Eventually, I need to add YES/NO questions and pausing/continuing(already did once before in the old Quest of Courage).  Right now, I just want to get damn hyphens to work.  I'd rather have hyphens than newlines if possible.  Just a design choice of mine.
« Last Edit: November 02, 2013, 10:24:27 am by Theforeshadower »
Logged
  • Super Fan Gamers!
Pages: [1]   Go Up

 


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



Page created in 0.046 seconds with 36 queries.

anything