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

Meystari F

Well I tried. I won't work

Spoiler
Code: ags
String phone_name[5];
int answer_count;
[close]


Spoiler


Code: ags
function OK_OnClick(GUIControl *control, MouseButton button)
{

phone_name[answer_count] = txtParserInput.Text; 
if (answer_count == 0){
if (txtParserInput.Text.CompareTo("555-6969") == 0){
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!!");
}
if (answer_count == 1){
  Display("What is the name of your favourite sex partner?");
}
else if (answer_count == 2){
Display("What is the best part of your partner's anatomy?");
}
else if (answer_count == 3){
Display("What do the two of you like to do together?");
}
else if (answer_count == 4){
Display("What is the best part of your body?");
}
else if (answer_count == 5){
 Display("And, finally, name your partner's favorite object?"); 
}
answer_count++;

}
[close]

Spoiler
Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?",phoneName1,Phonename2);

Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.".Phonename3, PhoneName4,PhoneName5);
[close]

The second and the rest of the questions don't show up after the first question when I try to write in the Text parser box.
What am I doing wrong here?


Well I will stick with my plan of the solution. Since your solution isn't working for me.

horusr

well you have big if on top of every ifs and it won't work if answer_count is more than 0. Just remove first if. And please use insert code button.

Meystari F

Well I made some test demo video for you so you can see my progress.


Spoiler

PS. I know I forgot to turn that text box GUI off as you can see in this video. But this was only made to show you what my problem is.

Questions don't show up.

horusr

You can also change "please enter phone number" text. Did you remove that if I mentioned and tryed again?

Oh and, thank you for video, you are really going good. Did you take original game graphics?

Meystari F

Thanks.

Yes I use original backgrounds and everything else.

But I also made some change too. Like adding a label on the table where the clerk is.
And as you could see some words were in Icelandic. I could upload more demo from my game later but not now.

I going to try your solution again tomorrow. I don't have more time for this now. I have to get to work on my real job. :)

Thanks again for your help.

horusr

I am happy "if" I could help.
Have a nice work day(whatever your job is)!

Meystari F

I'm a paperboy. It is like a mailman. But I'm only mail morning papers and magazines.

But here is a just a little bit longer demo of my game. But as you can see there is still errors I need to fix.
But you can see I add some more funny things in this game just for fun.

Spoiler


horusr

Whay it is only half English?
I tried to play first game, one with larry 7 like graphics and Softporn Adventure, but never be able to finish it :D

Ah, and, yu have some cool job!

Meystari F

Well I haven't yet translate all of the English words.  There are many things I need to fix. But this was only made for you to show you my progress.  Of course there is lots more I have done. Maybe I will upload it later in this week. And thanks again.

horusr

Keep up the good work and thanks for showing!
If you stuck again you can allways ask to Khris, he will be happy to help(me? I am still a noob)

Khris

Since this is about reading a single line of textual input, AGS has a built-in function for that: Game.InputBox()

Here's how to use that for the sex survey:
Code: ags
String name, p_part, like, y_part, p_obj;

function OK_OnClick(GUIControl *control, MouseButton button) {

  String number = txtParserInput.Text;

  if (number.CompareTo("555-6969") == 0) {
     
    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!!");
    
    name =   Game.InputBox("What is the name of your favourite sex partner?");
    p_part = Game.InputBox("What is the best part of your partner's anatomy?");
    like =   Game.InputBox("What do the two of you like to do together?");
    y_part = Game.InputBox("What is the best part of your body?");
    p_obj =  Game.InputBox("And, finally, name your partner's favorite object?"); 
    
    Display("Thank you for your answers. Bye!");
  }
  else Display("You let it ring a few times but nobody is answering.");
}


function blah() {
  Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
  Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
}


Even if AGS didn't have that function, or if you want to customize the look of it, the solution is to write a custom function and use that, exactly like I showed you in my very first reply in this thread.
Also note how this is instantly more readable due to proper indentation and descriptive variable names.

Meystari F

Thanks Khris for that. I will try this tomorrow.

Here is a another Video demo of my second game I am also working on.  And it is called "Quest for Heroes".

This is just a fan game for Quest for Glory fans.

Quest for Heroes  - Testing video.

Thanks again for this Khris.

Snarky

Khris, you'd set p_part twice and p_obj not at all. I fixed it using magic mod powers. Hope you don't mind.


Meystari F

Ok I have tested this.

Well the questions text line was too small for that inputbox.
But no worries. I edit that part and did this.

Code: ags
Display("What is the name of your favourite sex partner?")
 name =   Game.InputBox();
Display("What is the best part of[your partner's anatomy?");
 p_part = Game.InputBox();


This looks better in this way.

But I wish I could know how to get this works in custom inputbox instead of the normal game.inputbox.

Right now I'm having problem to display the last text after I have clicked on the hotspot I called "hPhone" once.

But as you know Larry has to leave the room and come back in the room
And he has to pick up the phone to get this reply from the sex-line number 555-6969

Code: ags
 function blah() {
  Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
  Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
}


All I have done is this .

Code: ags
function hPhone_Interact()
{
  if (Phonecall == 0){
gPhone.Visible = true;
  }
 else if (Phonecall == 1){
  if (HasPlayerBeenInRoom(16)) { 
 if (HasPlayerBeenInRoom(19)) {
gPhone.Visible = false;
String number = txtParserInput.Text;
String name, p_part, like, y_part, p_obj;
Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
}  
  }
 }
}


But it is not working.  So what am I doing wrong in this time? Please help me with this.

Khris

Keep track of the survey state:
Code: ags
// room script

String name, p_part, like, y_part, p_obj;
int survey_state = 0; // not called yet

function room_Leave() // this has to be created/linked in the room's events!
{
  // upon leaving the room, if survey was completed, advance state
  if (survey_state == 1) survey_state = 2;
}


Now add a function for the survey to the room script:
Code: ags
function conduct_survey()
{
  if (survey_state == 0) {
    // ask questions here
    survey_state = 1;
  }
  else if (survey_state == 1) Display("some message about trying again later to get results");
  else if (survey_state == 2){
    Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
    Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
  }
}


When the player interacts with the phone, show the GUI:

Code: ags
function hPhone_Interact()
{
  gPhone.Visible = true;
}


handle the GUI's OK button click in the global script, but send it back to the room script
Code: ags
function OK_OnClick(GUIControl *control, MouseButton button)
{
  CallRoomScript(1); // 1 = phone call
}


Finally, in the room script, handle making a phone call:
Code: ags
function on_call(int param) {  // clicking OK calls on_call(1);
  if (param == 1) // phone call
  {
    gPhone.Visible = false;
    String number = txtParserInput.Text;
    if (number.CompareTo("555-6969") == 0) conduct_survey();
    else Display("That number is apparently out of service.");
  }
}


Also note how this is instantly more readable due to proper indentation and descriptive variable names.

Meystari F

You are a genius Khris ;-D

It works now!

Thanks again for the wonderful help.


SMF spam blocked by CleanTalk