Fun with string manipulation

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: Fun with string manipulation
Apprentice
Member # 4656
Profile #0
I have two questions:

First, is there any way to use a string variable inside a dialogue as part of the "answer" text (text1, text2, etc.)?

Specifically, I'm trying to have an NPC say something in reference to a member of the party who is a slith, and have the NPC use the character's name in the text. Here's what I'm trying (probably in vain) to do:

variables;

short char_number = 0;
string char_addressed;

code =

if (species_in_party(3) == 1) {
while (get_species(char_number) != 3) {
char_number = char_number + 1;
}
clear_buffer();
append_string("The mayor glances uneasily at ");
append_char_name(char_number);
append_string(". _No offense intended, of course._");
get_buffer_text(char_addressed);
print_str(char_addressed);
}
break;
Obviously this is goofy and not much use while in a dialogue, because print_str only outputs to the little text area beneath the play screen, and I get underscores instead of quote marks.

My second question is related to the first, but far more stupid: How can I output a variable stored with the get_buffer_text call to a plain old dialogue box?

Thanks for any guidance!

--------------------
I ain't no ******* son of a *****.
You better think about it, baby.
Posts: 29 | Registered: Saturday, July 3 2004 07:00
Off With Their Heads
Member # 4045
Profile Homepage #1
Um, I haven't tried it, but I think the way to use string manipulation in dialogue is to use the message_dialog call. The call print_str won't do it -- that just prints a line in the text area, which isn't what you want.

To use string manipulation in regular dialog boxes, well, you're pretty much there already. Once you've saved the string you want as whatever name you like (I like dlgstr, myself, as a compresssed form of the phrase "dialog string," but obviously you can use anything), just use whatever call you would normally use to set up the dialog. If it's short, it will look like this:

quote:
message_dialog(dlgstr,"");
or you can get a longer message with add_dialog_str

add_dialog_str(0,dlgstr,0); Everything else is the same as what you've already done.

The HLPM v1.0.2 has examples of this, in state 20 of the town script for instance, although this version isn't terribly clear. The next version, v1.1, will have comments all over it so you can follow along, and it will be out tomorrow.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 2820
Profile #2
I'm not sure if this will work because I don't think you can call this inside of a dialog script since it you don't really script inside it.

--------------------
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
Off With Their Heads
Member # 4045
Profile Homepage #3
I don't quite know what Keep is talking about. That's what the "code = " thing is there for.

[ Tuesday, July 20, 2004 13:18: Message edited by: Just call me Kel ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Apprentice
Member # 4656
Profile #4
Thanks Kel, I've managed to beat my poor script into submission using message_dialog() while in dialogue mode. It ain't pretty, but at least now it does what I want it to do. :)

--------------------
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 #5
quote:
Originally written by 20eyes:

Thanks Kel, I've managed to beat my poor script into submission using message_dialog() while in dialogue mode. It ain't pretty, but at least now it does what I want it to do. :)
Try using clear strings() in the code. Then make conditions to show different texts. EX:
code =
clear_strings();
if (condition 1) {
add_string(number of text, text1 - 8. NUMBER ONLY!
}
if (condition 2) {
add_string(same as above)
break;
Posts: 249 | Registered: Saturday, July 26 2003 07:00
Off With Their Heads
Member # 4045
Profile Homepage #6
That won't get you a character's name, GIFTS.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Apprentice
Member # 4656
Profile #7
Yeah, been there done that, GIFTS. My original code still contains the remnants of a few failed add_string attempts that are very similar to your suggestion.

message_dialog("blahblah",x), I believe, is the only call that can output buffer text *while in dialogue mode* (where x = the buffer text). If anyone knows any different, please correct me!

At any rate, my script is humming along nicely now, so it's all good. Now my NPC's can recognize the species of every PC in the player's party and say nifty things like "Aldous, you're a pitiful excuse for a human" and "Trust me, I know a slith fart when I smell one. No more broccoli for you tonight, Ssschah."

The fun never ends.

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