I read the manual thiny, and I dont get this buffer text thingy

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: I read the manual thiny, and I dont get this buffer text thingy
Shock Trooper
Member # 3276
Profile #0
whats the use of buffer text when I have print_str_color code? Can someone explain to me how to use this please.
Posts: 249 | Registered: Saturday, July 26 2003 07:00
Agent
Member # 2820
Profile #1
What kind of code can you put into print_str_color()? You can either put a single literal ("Hi everybody!"), or a string CONSTANT, but not both.

You can't append anything to the constant, and the literal must be given in its entirety. There is no flexibility in this regard, but the buffer calls can at least allow you to append a mix of strings and numbers together, and then you can dump the buffer into a string, which is the only time when you can change the string constant.

[ Thursday, July 22, 2004 17:10: Message edited by: Keep ]

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Shock Trooper
Member # 3276
Profile #2
quote:
Originally written by Keep:

What kind of code can you put into print_str_color()? You can either put a single literal ("Hi everybody!"), or a string CONSTANT, but not both.

You can't append anything to the constant, and the literal must be given in its entirety. There is no flexibility in this regard, but the buffer calls can at least allow you to append a mix of strings and numbers together, and then you can dump the buffer into a string, which is the only time when you can change the string constant.

Okay, HOW do I do that? I don't understand how to use the buffer.
Posts: 249 | Registered: Saturday, July 26 2003 07:00
Apprentice
Member # 4656
Profile #3
Did you read the section in the appendix on string manipulation? It's pretty self-explanatory. Basically the text buffer just gives you a way to do some really nifty things with string variables to customize text output.

For instance, you could do something like this:

code =
if (species_in_party(3) == 1) { // If there's a slith in the player's party
while (get_species(char_number) != 3) { // Cycle through PC's to identify the slith
char_number = char_number + 1;
}
clear_buffer(); // Prep the buffer by emptying it out
append_string("Bob frowns at "); // Add this text into the buffer
append_char_name(char_number); // Tack the slith PC's name onto the end of the text above
append_string(". _And that includes you._"); // Add this text after the PC's name
get_buffer_text(char_addressed); // Assigns all the text we just made to variable char_addressed
message_dialog("_I don't deal with sliths._",char_addressed); // Displays the first text in a dialog, followed by the buffer text we just created
}
break;
So the final result is, if the player has a slith named Ssschah in his party, the text the player sees in the dialog will now read:

"I don't deal with sliths." Bob frowns at Ssschah. "And that includes you."

In this example, we've used the text buffer to "build" a custom chunk of text using a literal and a constant, which is something that would be impossible to do without the string manipulation calls and the text buffer.

[ Thursday, July 22, 2004 18:58: Message edited by: 20eyes ]

--------------------
I ain't no ******* son of a *****.
You better think about it, baby.
Posts: 29 | Registered: Saturday, July 3 2004 07:00
Shock Trooper
Member # 3276
Profile #4
Okay, I get it now. Thanks. EDIT: I think.
EDIT:
The variables were
short char_number;
string char_addressed;
Can I uas any string variable or any interger variable or does it have to be those

[ Friday, July 23, 2004 06:07: Message edited by: GIFTSare2cudly ]
Posts: 249 | Registered: Saturday, July 26 2003 07:00
Agent
Member # 2820
Profile #5
Any declared string variable is fine.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Apprentice
Member # 4656
Profile #6
Right,

short char_number = 0;
string char_addressed;

are just the ones I chose for the example.
You can call them anything you like.

--------------------
I ain't no ******* son of a *****.
You better think about it, baby.
Posts: 29 | Registered: Saturday, July 3 2004 07:00