Garrulous Glaahk Yellow Sub Posted July 22, 2004 Share Posted July 22, 2004 whats the use of buffer text when I have print_str_color code? Can someone explain to me how to use this please. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 23, 2004 Share Posted July 23, 2004 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. Link to comment Share on other sites More sharing options...
Garrulous Glaahk Yellow Sub Posted July 23, 2004 Author Share Posted July 23, 2004 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. Link to comment Share on other sites More sharing options...
Curious Artila 20eyes Posted July 23, 2004 Share Posted July 23, 2004 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: 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. Link to comment Share on other sites More sharing options...
Garrulous Glaahk Yellow Sub Posted July 23, 2004 Author Share Posted July 23, 2004 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 Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 23, 2004 Share Posted July 23, 2004 Any declared string variable is fine. Link to comment Share on other sites More sharing options...
Curious Artila 20eyes Posted July 23, 2004 Share Posted July 23, 2004 Right, short char_number = 0; string char_addressed; are just the ones I chose for the example. You can call them anything you like. Link to comment Share on other sites More sharing options...
Recommended Posts