Jump to content

Photo

Printing strings


  • Please log in to reply
9 replies to this topic

#1 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 29 May 2012 - 03:04 PM

I can't figure out how to print a string (It must be done with drawstring, not Screen->Message). How does one go about writing the string in the code?

I'm doing it like this:
CODE
int buffer[256];
buffer = "STUFF"
Screen->DrawString( 7, screenWidth/3, 16, FONT_Z3, textColor, -1, TF_NORMAL, buffer, 128 );


But the compiler tells me
QUOTE
UNEXPECTED QUOTEDSTRING, ON TOKEN "STUFF"


What am I doing wrong?

#2 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 29 May 2012 - 03:23 PM

Missing a semicolon after "STUFF". Can you assign the array reference like that?

What about doing it like this: int buffer[] = "STUFF";

#3 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 29 May 2012 - 04:02 PM

Okay, now it compiles but the strings don't show.

#4 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 29 May 2012 - 04:23 PM

Haven't used it before, but if it's anything like the other draw methods it needs be called at every frame.

#5 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 29 May 2012 - 04:26 PM

And it does get called every frame...

#6 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 29 May 2012 - 04:27 PM

Sorry, can't really tell with only having 3 lines of the script. Can you post more?

#7 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 29 May 2012 - 04:54 PM

Sure I can.

I used multiple arrays (inefficient, I know) because it didn't like buffer = "STUFF".

CODE
else if ( levelOver ){ //If level over flag set by FFC script
                Game->PlayMIDI(9);                                    //I've confirmed it gets at least this far
                int newScore = getScore( Game->GetCurDMap(), levelTime, levelKills, levelDamage ); //Find current score
                if ( newScore > levelScore[Game->GetCurDMap()] ) levelScore[Game->GetCurDMap()] = newScore; //Save if higher than highest score
                Link->PressA = false;
                while ( !Link->PressA ){ //Until Link presses A
                    int buffer[256] = "Mission complete!";
                    Screen->DrawString( 7, screenWidth/3, 16, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer, 128 );
                    int buffer2[256] = "Time to complete: ";
                    Screen->DrawString( 7, screenWidth/3, 32, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer2, 128 );
                    Screen->DrawInteger( 7, 2*screenWidth/3, 32, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, -1, -1, levelTime, 0, 128 );
                    int buffer3[256] = "Enemies killed: ";
                    Screen->DrawString( 7, screenWidth/3, 48, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer3, 128 );
                    Screen->DrawInteger( 7, 2*screenWidth/3, 48, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, -1, -1, levelKills, 0, 128 );
                    int buffer4[256] = "Damage taken: ";
                    Screen->DrawString( 7, screenWidth/3, 64, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer4, 128 );
                    Screen->DrawInteger( 7, 2*screenWidth/3, 64, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, -1, -1, levelDamage, 0, 128 );
                    int buffer5[256] = "LEVEL SCORE/RECORD: ";
                    Screen->DrawString( 7, screenWidth/3, 80, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer5, 128 );
                    Screen->DrawInteger( 7, 2*screenWidth/3, 80, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, -1, -1, newScore, 0, 128 );
                    Screen->DrawInteger( 7, 2*screenWidth/3+32, 80, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, -1, -1, levelScore[Game->GetCurDMap()], 0, 128 );
                    int buffer6[256] = "Press A to continue";
                    Screen->DrawString( 7, screenWidth/3, 96, FONT_Z3, TEXTCOLOR, TEXTBGCOLOR, TF_NORMAL, buffer6, 128 );
                    
                    WaitNoAction();
                }
                levelOver = false;
                Link->Warp(0,0);
            }

Edited by MoscowModder, 29 May 2012 - 04:55 PM.


#8 tox_von

tox_von

    Zelda Addict

  • Members
  • Real Name:Redgor
  • Location:Toxicville , Simcity

Posted 29 May 2012 - 06:19 PM

was this what you mean?

CODE
import "std.zh"

int string1[] = "string1";

ffc script new_script
{
    void run()
    {
       while (true)
       {
       Screen->DrawString( 1, 10, 10, FONT_Z1, 1, 0,TF_NORMAL, string1, 128 );      
       Waitframe();
       }
    }
}


#9 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 May 2012 - 07:40 PM

Do you have the rule "Subscreen Appears Above Sprites" enabled? Drawing on layer 7 is disabled, otherwise (which should probably be changed).

#10 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 29 May 2012 - 09:03 PM

I did not know that. Works now!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users