Jump to content

Noob question re: dialogue


Jerakeen

Recommended Posts

I think that you'll (in the code section of the relevant node) first need to use the string buffer to construct the string to display (using append_char_name(), in particular), and then use message_dialog() to inject the result into the dialogue system.

 

This will restrict you to having only two chunks of text, total, displayed for that node (I think), but this is the only way to display dynamically generated text that I know of, off of the top of my head.

Link to comment
Share on other sites

Ah. That would explain why it isn't done more often.

 

My understanding is that the string buffer replaces any strings that were already in the node, but I assume you can make its activation conditional, say on an SDF? (Please remember that I'm not a programmer.)

 

If anyone can remember a scenario in which this is done, I would find it extremely helpful to be able to look at it in practice.

 

Thanks for the quick reply.

 

Link to comment
Share on other sites

Quote:
My understanding is that the string buffer replaces any strings that were already in the node, but I assume you can make its activation conditional, say on an SDF? (Please remember that I'm not a programmer.)

You're mixing together a couple of ideas here.

The string buffer is just a piece of scratch space set aside for you to build up strings in. The usual pattern is to erase whatever is in the buffer, make some calls which write pieces data into the buffer (each one adding onto the end of what is already in the buffer), and then copy the contents of the buffer into a string variable, so that it can be sent to some other call which will do something with the string (like display it).

The message_dialog() call has two uses. The first is the one that you are no doubt already familiar with: showing a dialog box with the two given strings as the contents. The second is related but subtly different: When message_dialog() is called from the code section of a dialogue node, it replaces all 8 of the usual text strings with the two strings passed to it as it's arguments.

Since the dialogue node code section can contain arbitrary script constructs, you can put in whatever logic you want build up strings and to decide whether you do or don't want to use message_dialog() to replace the node text. Unfortunately, I don't remember an example of this in an existing scenario off of the top of my head, but here's a rough example of how it might look:

Code:
begintalknode 1;	state = 0;	nextstate = 0;	question = "Who am I?";	text1 = "_I'm sorry, I have no idea who you are._ the shopkeeper says. ";	code = 		if(get_flag(1,1)){ //killed the dragon			clear_buffer();			append_string("_Of course!_ he cries, _You're ");			append_char_name(0);			append_string(" who slew the dragon!_");			get_buffer_text(s); //assume a string variable named s			message_dialog(s,"");	}	break; 
Link to comment
Share on other sites

OK, I think I'm understanding you. And in this example, s would be defined in the dialogue script variables?

 

I've found a few examples in town scripts for things like "So-and-so has just learned a level of Create Illusions." and so forth. I'll play around with these until I get it through my head.

 

Thanks for the explanation, Niemand. :-)

Link to comment
Share on other sites

  • 1 month later...

You can also use 'run_dialog()' from a talk node if you need more than 2 lines of text.

 

From Amnesia:

Code:
begintalkscript;variables;short val, choice;string valline;...begintalknode 9;	state = 7;	personality = 56;	nextstate = -1;	condition = (get_flag(50, 10) > 0);	question = "Yes, let me know.";	text1 = "Angus answers your question before getting back to work.";	action = END_TALK;	code =		val = get_flag(50, 3);		clear_buffer();		append_string("'The number was ");		append_number(val);		append_string(".'");		get_buffer_text(valline);		reset_dialog();		add_dialog_str(0, "Angus pauses then says:", 0);		add_dialog_str(1, valline, 20);		add_dialog_str(2, "'But golly gee, I'm not real sure.' he adds.", 0);		add_dialog_choice(0, "Ok");		choice = run_dialog(1);	break;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...