Code diagnostics plz

Posted by Taizen Chisou on May 8, 2012, 5:35 p.m.

Honestly, I just put this together, so perhaps it was utterly foolish of me to expect this to work.

The idea is that the text object takes it's given string and separates it into smaller strings each with different parameters.

It takes a string like

"The idea is /inot /cto destroy the /bstrange monsters, /cbut rather to take them alive for further inspection by /ySeamus."

and turns it into

"The idea is not to destroy the strange monsters, but rather to take them alive for further inspection by Seamus."

For some reason, it doesn't do this.

All of the ministrings are blank and the formatting is not present.

length = string_length(str);

while(parseStringPos < length)
    {
    parseStringPos += 1;
    changed = false;
    
    if (string_char_at(str,parseStringPos) == "")
        {
        parseStringPos+=1;
        
        if ((string_char_at(str,parseStringPos) == "i") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringFormatting[currentString] = 1;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
        if ((string_char_at(str,parseStringPos) == "b") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringColor[currentString] = c_blue;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
         if ((string_char_at(str,parseStringPos) == "g") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringColor[currentString] = c_lime;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
         if ((string_char_at(str,parseStringPos) == "r") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringColor[currentString] = c_red;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
          if ((string_char_at(str,parseStringPos) == "y") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringColor[currentString] = c_yellow;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
          if ((string_char_at(str,parseStringPos) == "s") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            stringEffect[currentString] = 1;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            parseStringPos += 1;
            }
          if ((string_char_at(str,parseStringPos) == "c") && (changed = false))
            {
            changed = true;
            currentString += 1;
            totalStrings += 1;
            parseStringPos += 1;
            stringStartXinc[currentString] = stringStartXinc[currentString-1]+string_width(stringText[currentString-1]);
            stringStartYinc[currentString] = stringStartYinc[currentString-1];
            }
                
        }
    else if (string_char_at(str,parseStringPos) != "#")
        {
        stringText[currentString] += string_char_at(str,parseStringPos);
        }
    else
        {
        currentString += 1;
        totalStrings += 1;
        stringLines += 1;
        stringStartXinc[currentString] = 0;
        stringStartYinc[currentString] = stringLines * 12;
        stringColor[currentString] = stringColor[currentString-1];
        stringFormatting[currentString] = stringFormatting[currentString-1];
        stringEffect[currentString] = stringEffect[currentString-1];
        }
    }

Comments

Toast 12 years, 7 months ago

I'm feeling proud of myself because I have no idea what you're referencing

Juju 12 years, 7 months ago

Oh bugger, I've noticed a glitch. string_width() will return different values for italic/bold/different sized text even if the string is identical. You'll need to assign relevant parameters to the internal font system to get the spacing to work properly.

This is the reset code, I believe:

            case "c": { //Reset to normal text
                previousString = currentString //Saves on a little processing time
                currentString += 1; //Move register to the next row of the arrays
                totalStrings += 1;
                parseStringPos += 1;
                
                stringStartXinc[currentString] = stringStartXinc[previousString]+string_width(stringText[previousString]); //Space out along x axis
                tringStartYinc[currentString] = stringStartYinc[previousString]; //Align with previous y coord
                
                stringText[currentString] = ""; //Set stringText to empty
                stringFormatting[currentString] = 0; //Set stringFormatting
                stringColor[currentString] = c_black; //Set stringColor
                stringEffect[currentString] = 0; //Set stringEffect string
                break
            }

For the record, I didn't know this was for the competition.

Taizen Chisou 12 years, 7 months ago

So, wait. We're not allowed to ask for assistance on our entries?

What the fuck.

Castypher 12 years, 7 months ago

I'm sure that's not the case since some people are using entire engines. And without a doubt, the RPG Maker people are Googling scripts as we speak.

Toast 12 years, 7 months ago

Ok, Taizen is now genuinely disqualified for not understanding sarcasm

Castypher 12 years, 7 months ago

It was nice competing against you, Taizen. Even if just for a week.

Taizen Chisou 12 years, 7 months ago

I was going to make a sarcastic remark, but then I realized that I didn't know if you were being serious <3

Toast 12 years, 7 months ago

Of course I was being serious, everbodies is disqualifieds.