How can I let NPC Memorize all words and repeat what player said? (Solved)

Started by Meystari F, Tue 13/06/2017 08:20:22

Previous topic - Next topic

Khris


horusr

I think the answer could be "rol" or "anyword". This is from manual's text parser part:

QuoteThere are a couple of special words you can use with the Said command. "anyword" will match any word that the user types in. For example, Said("throw anyword away") will match if they type "throw dagger away", or "throw trash away". "rol" (short for Rest-of-Line) will match the rest of the user's input. So, you might want to do:
Code: ags
if (Parser.Said("kill rol")) {
  Display("You're not a violent person.");
}


This way if they try to kill anything they will get the generic response.

Meystari F

No that is not the right answer.
because the game has to remember and repeat the word you typed in.

Lets just say if I ask this.   What is your name?   Your answer: Jon Jonsson (Or just any name you want to say)
and then I will next ask you.  What are you doing now?  Your answer: Nothing...(just type whatever you want to say).
And then again I will ask you.      What would you like to do?    You answer: play computer games (or just type whatever words you want to type)

Later the game will say to you after you have typed in the words of your choice. 

Hello, "Jon jonson", I see you are doing "nothing", I'm also very alone. Come with me and let's "play computer games"!

This is just like it happens when Larry make a phone-call in Leisure suit Larry 1.
   
So do you have any answer how to make a code for this?




Khris

Just create variables and use them, it's really not that hard. Don't just ask for code, try to understand how this works.

Assuming you created a global String variable called phoneName:
Code: ags
  phoneName = txtParserInput.Text;


Later, when you want to use the stored value:
Code: ags
  Display("Hello, %s!", phoneName);



Edit: Snarky posted what I should've posted earlier.

Snarky

Edit: Let me refer you to the title of this thread: "How can I let NPC Memorize all words and repeat what player said? (Solved)"

So you do the same thing we already explained earlier.

You're having the same problem as before: needing to store text input that you will then use later. Why would you think the answer is any different than it was the first time?

We can't keep telling you how to do the same thing over and over again, so when you ask again after we already explained it, that makes us want to give up, because clearly we're not getting through to you.

Meystari F

I'm very close to understand this now.

I'm using a custom GUI for the inputbox which I call gTextparser because the normal game.inputbox are too small to put in the questions.
So what code do I use to change it for my gTxtparser.

This code only works for the normal game.Inputbox.  Is there any way I can enlarge the normal game.inputbox so the question could fit in that inputbox ?


Code: ags
String Ask(String question, String option1, String option2) {
  String input;
  while (true) {
    input = Game.InputBox(question);
    if (input.CompareTo(option1) == 0) return option1;
    if (input.CompareTo(option2) == 0) return option2;
  }
}

[/s]

Nevermind that.   I have a better idea how I should make those question. I use the dialog.

Meystari F

I have finally found the right and final solution for my issue.

First Make a global String called Answer.
or add this in the main room.

Code: ags
String Answer ="";
String Answer1 ="";
String Answer2 ="";
...



After that I make a gui called gQuestion
Then I make a button called OK
and Textbox which I call txtParserInput.
I press on the OK button and add this code in

Code: ags
if (txtParserInput.Text.CompareTo("555-6969") == 0){
gQuestion.Visible = false;
Display("Hello, you have reached the National Hot Line Sex Survey. Please answer the following questions. There may be a wonderful prize waiting for you!!");
Display("What is the name of your favourite sex partner?");
gQuestion2.Visible = true;


Then I make a copy of that same GUI by clicking on Export GUI and after that I import it and name it gQuestion2 and gQuestion3 and so on.

Make sure you change the name on the buttons to Ok2 and OK3  and txtParserInput as txtParserInput2 and txtParserInput3

Then again click on the OK2 button and add this code.

Code: ags
Answer1 = txtParserInput2.Text;
gQuestion2.Visible = false;
Display("Any  question you want to ask");
gQuestion3.Visible = true;


And then you click on the Question3 and the button OK3
and add this code.

Code: ags
Answer2 = txtParserInput3.Text;
Display("Any  question you want to ask");
gQuestion4.Visible = false;


That's it!


And then finally whenever you want to display this message

Code: ags
Display("Whatever you want to say, %s,%s",Answer1,Answer2);


I hope this final solution will help others beginners on codings on AGS like I am.
But I'm too doing my best to understand and learn on AGS.

horusr

Congratz! But I believe there must be better ways than creating same gui again and again.

Meystari F

Perhaps true, but this is at least much easier in this way. I'm not a expert in coding.

Snarky



horusr

I think you can use just an integer and 1 gui for it. Like if int answer_count == 0 then store inputted text into answer1(well I also think you can use array of strings instead of multiple strings).
And this is probably not that good way but easier. I dont know much about text parser.

Meystari F

Quote from: horusr on Mon 24/07/2017 12:51:26
I think you can use just an integer and 1 gui for it. Like if int answer_count == 0 then store inputted text into answer1(well I also think you can use array of strings instead of multiple strings).
And this is probably not that good way but easier. I dont know much about text parser.

Please show me how.   What is the code?

QuoteI don't know much about text parser.
Me neither.
But this is the only room in the game I need to have a Questions with text parser included.
Because I want the player write his own answer on a text parser. That is way this was getting very difficult for me to write a code for it.
My whole game are not going to be text parser game. But just a little bit.



Meystari F

Quote from: Khris on Mon 24/07/2017 12:19:14
It's an egregious violation of https://en.wikipedia.org/wiki/Don%27t_repeat_yourself

Hehe sorry that! But I had no other ideas how to solve this. No one here wanted to help me so I had to figure this out on my own way.


Ps. What does  "egregious" means?  Google translator are not helping me but it don't display the Icelandic words it.

horusr

Can you send full code to let me make changes on it? In spoiler tags?

Meystari F

Can't you use the code I showed above?

Spoiler


function Button15_OnClick(GUIControl *control, MouseButton button)
{
if (txtParserInput.Text.CompareTo("555-6969") == 0){
gSmokkur.Visible = false;
Display("Hello, you have reached the National Hot Line Sex Survey. Please answer the following questions. There may be a wonderful prize waiting for you!!");
Display("What is the name of your favourite sex partner?");
gSmokkur3.Visible = true;
}
}

function OK2_OnClick(GUIControl *control, MouseButton button)
{
phoneName1 = txtParserInput2.Text;
Display("Hello,%s",phoneName1);
gSmokkur3.Visible = false;
gSmokkur4.Visible = true;
}


function OK3_OnClick(GUIControl *control, MouseButton button)
{
phoneName2 = txtParserInput3.Text;
Display("Hello,%s",phoneName1);
gSmokkur3.Visible = false;
gSmokkur4.Visible = true;
}
[close]

horusr

I will try but you need to tell me where do you store normal answers and how you manage different questions.

Let's try:

Code: ags

String phone_name[3];
int answer_count;

if (txtParserInput.Text.CompareTo("555-6969") == 0){
gQuestion.Visible = false;
Display("Hello, you have reached the National Hot Line Sex Survey. Please answer the following questions. There may be a wonderful prize waiting for you!!");
Display("What is the name of your favourite sex partner?");
gQuestion2.Visible = true;
answer_count++;
}

phone_name[answer_count] = txtParserInput2.Text;
Display("Any  question you want to ask");
answer_count++;


kind f this code. It won't work probably and you don't need to create second GUI but I don't know how your code works.

Meystari F

This is just like in Leisure Suit Larry 1 when he make a phonecall.

Scroll to 9:35

Spoiler
I'm trying to remake Leisure suit Larry 1 but I'm going to include Icelandic language with that game.
[close]


Meystari F

Well I tried your code.  It did not work as I wanted it to be.

What happens is this. I don't have a chance to write the answer because all questions display in each time when I click Ok button.

horusr

Simple use if else if statement.

Code: ags
if (answer_count == 1) Display(question) ;
Else if (answer_count== 2) Display(other question); 

SMF spam blocked by CleanTalk