Type answer in a conversation

Can someone please help with a script that allows you to type the player’s response in a standard conversation instead of the usual multiple choices?

I wouldn‘t mind if the player‘s response would still start with the standard „1.“ for the first possible answer, but after that the player should be able to type the answer himself.

I‘m aware that custom text input is possible in general and that it‘s implemented in modules like The Scroll, but I didn‘t find how to do it in a custom conversation (and not in a pop up window.)

I would love to use that for a module that I have in the works.

Any help is greatly appreciated!

I don’t believe it possible to do it in any other way than in a custom pop up window, Iike I’ve done it in my last two modules A Strange World IV: The Traveler and At A Distant Shore.
I’m also using this in the module I’m working on now. Works really well, I think. You could look into those modules if you wish, or I could send you the custom XML code I have done. (I believe kevL_s and 4760 helped me to some extent with this, but I know that in the end I manipulated the graphics for that window myself to get it to look the way I wanted)

Don’t know if you’re after that the player should be able to put in text in the chat window? Why would that be better than in a pop up window?
Or, I mean, to somehow use the normal NWN1 style conversation window and type directly into that…Don’t know how one would accomplish that. That would, if possible, require some extensive and advanced XML GUI programming.

EDIT: I found the thread where I, kevL_s and Lance discuss this at length. I also found another thread where 4760 showed me how to do this in the first place. You can read through them and use what you like:

1 Like

It’s ends up a bit ugly because of the order in which conversation nodes check conditionals to determine which node follows, but you can try putting this in your On Conversation script:

void main()
{
	string sStringHeard = GetMatchedSubstring(0);
	if (IsInConversation(OBJECT_SELF))
	{
		if (TestStringAgainstPattern("**TESTSTRINGHERE**", sStringHeard) == TRUE)
			SetLocalInt(OBJECT_SELF, "TESTVAR", TRUE);
		SetListening(OBJECT_SELF, FALSE);
		ActionResumeConversation();
	}
	else
		BeginConversation();
}

Substitute variable names and “TESTSTRINGHERE” as desired obviously.

Here’s a screenshot of an example conversation (note that it needs to be NWN1-style, and multiplayer cutscene unchecked):

pause_conversation is this script:

void main()
{
	SetLocalInt(OBJECT_SELF, "TESTVAR", FALSE);
	SetListening(OBJECT_SELF, TRUE);
	SetListenPattern(OBJECT_SELF, "**", 0);
	ActionPauseConversation();
}

This should result in giving the conversation node “It matched.”, if the player types “TESTSTRINGHERE”.

2 Likes

@Akhacha - This was interesting. Have never used the SetListening function. Do you type what you want in the chat window then?

Correct, hence why the conversation needs to be NWN1-style, otherwise the game won’t let you open the chat window.

1 Like

Thank you, @andgalf and @Akhacha !

(I’m not all against pop up windows, but I thought it might be a bit more elegant to have the player’s input directly in the player’s response field.)

I am currently toying with Andgalfs solution, but would want to alter the layout of the input box. I am wondering which xml-file is linked to the DisplayInputBox-function? (It seems there is no “input”-xml or the like …?)

1 Like

Ok, found it:

stringinputmessagebox.xml

1 Like

Works like a charm and adds another dimension to quests and riddles.

No more multiple choice!

1 Like

Yep, I use it quite a lot too. But I still use the multiple choice approach as well.

2 Likes

Me too. But finally I can do real word riddles, making the player read a book to find the answer. Very cool.

Yeah, that’s one way of doing it which I haven’t implemented yet. I have used riddles where the player just have to figure out the answer himself/herself, or there’s an alternative where they can ask one of the companions.

2 Likes