A chat simulation with saving the last phrase

Hello! I have the idea of ​​a text-graphic quest, imitation of a chat, or something like that, haha. It will be only one screen (first, the main menu with several buttons is visible, and then it will be hidden when the user starts or continues the game).

In this connection, I have 2 questions.

  1. How to change bot messages that go one after another? Suppose I have 50 questions that mimic a conversation. How to implement this? The screenshot shows what I mean. That is, the user clicks on the “New chat” button. So the greeting appears. The user answers and clicks on the “Send” button. So they see a new question. But how to make the second, third, and so on questions appear the next time they click on the “Send” button? I can’t just copy this block and paste another text (I know that the “Send” button is busy, I only duplicated these blocks in the screenshot to explain my idea of ​​sequential questions).

  2. How to save the current position of the screen? Suppose the user reaches 35 questions. He/she wants to close the application and continue the game next time from this place. I want to do two ways:

  3. The user clicks on the “Save” button.

  4. The user clicks on the “Back” button, it automatically saves in case they did it by accident.

Yre you really using the when Send Click block three times? Not possible. OYu have to work with if/else conditions.

Yoshi

2 Likes

store your questions in a list and read the next item from the list in the Button.Click event

see also App Inventor Tutorials and Examples: Advanced Features | Pura Vida Apps
Taifun

2 Likes

No, no, of course, I know this is wrong. That’s why I wrote:

Thank you. Yes, I will carefully read about Lists. Thanks for answering my first question.

1 Like

@RusBoriska You can do it this way:

blocks (52)

blocks (54) blocks (56)

Please insert these to your project and tell me what happens. It’s completely untested…

1 Like

@RusBoriska how is it going?

1 Like

Many thanks. I just added this code and tested it. It turns out that everything works. There are a few things I want to add here. But I will ask these questions if I can’t do it myself.

Right now I have only two questions about lists.

  1. Can I upload all questions in one CSV file (each question in a separate cell)? And if so, how?
  2. How can I display a message or create an event after the last question? Well, something like, “Game over” and then show the main screen.

Welcome. Please mark the appropriate answer as solution.

Yoshi

Yes, I marked your answer as a solution to my main problem.

I will add here other questions related to lists later so as not to duplicate topics.

1 Like

I myself solved a couple of simple questions. But these so far remain unresolved.

I try to solve the second question through the total length of the list, but I get errors.

I think I have made the Send button correctly. At least now that the list ends, there is no error. Moreover, a message appears about the end of the game, the purchase of the full version or anything (this is just a blank).


Now I have only one question. How can I “feed” a CSV file (or any other) instead of adding blocks of text to the list (50 text blocks)?

1 Like

Do you mean the add items to list block? You can attach a list from csv row text block instead of item, I think. Idk however.

1 Like

Unfortunately, I can’t add all the questions from the file to the list. I guess I’m doing something wrong.

Here are the questions themselves from the file.
“Question 1”, “Question 2”, “Question 3”, “Question 4”, “Question 5”, “Question 6”, “Question 7”, “Question 8”, “Question 9”, “Question 10”

And here are the added blocks.

I tried adding the file differently, but the result is the same.

No, your blocks are wrong. First, you can’t put the csv Text block in the csv row text, You’ll have to type the items using “,” as a seperator all in the text field. Then, you are doing some other things wrong in the place where aou are getting the item. Somewhere, you try to get item number 0… check your blocks again…

1 Like

I don’t know yet how to correct my blocks. As for the contents of the CSV file, it looks as follows. All questions are in quotation marks and separated by commas.

No, you have to put it in this format

Question1,Question2,Question3,… (without quotations, and without spaces)
and insert into a text block attached to the list from csv row text block

Tell me if it works.

1 Like

If so, then it doesn’t work either. Or am I wrong?

Yes, remove the make a list block, it’s making a list of the list of the text :crazy_face:

Did it work now?

Have you tested it?

1 Like

Yes, I just checked. Now everything is working correctly. But only now I understand that such a method of inserting text is not suitable for me, since in the future it is planned to use long texts, inside which there will be its “own” commas. Does it mean that the best option is to use text blocks?

You can try out the other list blocks like list from csv table text, etc…

PS: If your problem is

pls mark the appropriate answer as solution.

Yoshi

1 Like