I have been going through the forums for the past few days and I am amazed by the quality of the advice provided here. I am trying to make a choice-based game and have seen some similar examples in the forum (for instance dialog-system_t65873) which have been of great help, especially @Yann. However, I am still unclear of what the best method is, so I am starting this thread.

My intention is to create a game as follows; the player is prompted a question (Q1) such as "You have encountered a bear. What do you want to do?" He is given two possible answers (1a and 1b), which could be 1a="fight!" and 1b="run!". Upon choosing an answer, I would like three things to happen:

1. Feedback is given to the player (for instance, if he chose 1b: "run!", output "player starts running towards the river")

2. After the feedback (on tap or click) the next question is presented, where answer 1a leads to question Q2 and 1b to Q3 (for instance: "You have reached the river, what do you want to do?"). Also, the possible answers to the Question should be displayed (3a:"Keep running" and 3b: "Jump into the river").

3. Points are assigned to 5 categories depending on the answer. For instance, answer 1a: "fight!" would give +2 points to strength and -3 to sanity.

From what I have read, I am guessing that the best option is to have a 2D array of feedbacks and questions and a 2D array with answers and their corresponding scores.

Therefore the relationship is:Row of Answer chosen leads to row of Feedback and Question +1

The problem is that I do not know how to link the two arrays using Construct 2. I only started with C2 recently, and have not explored all the possibilities yet, but I am guessing it would be necessary to have 3 text boxes, 1 for Qs and 2 for answers, and another layout with a feedback text box.On click of answer 1a, the scores should be added to global variables and the layout should change to the feedback text box. On another click the Q text box should be updated to Q2 and the answer text boxes to 2a and 2b.I am guessing I would have to use for loops to connect the arrays, but any guidance on how to do this would be greatly appreciated.

In case this method does not work, how bad it would be to do the game question by question (for approximately 500 questions)? For example, have the same 3 text boxes and writing down as events all the consequences of clicking one answer, in a sort of cumulative sub-events (I think)?

I apologise for the long post, I have tried to keep it abstract, just in case I get the help I need it will also help other people who are trying to find a way to relate the data of two different arrays.

This keeps all your questions and answers together in one array. NextQuestion points to the X value of the followup question for that particular answer. This makes it a lot easier if you want to change the pointer for the followup question or add new questions to the array.

I would also read up on how to store your array data in a JSON text file and import it with the AJAX object - it's going to be a whole lot easier editing a text file than updating all of those entries directly in Construct.

It just loops around between the questions, answers and feedback, but covers the basics. You could simplify this further by shifting some of the repeated actions into functions, but I've left it as is to make it easier to follow what's going on.

Click an answer to select it, click the feedback to progress to the next question.

There are comments in the event sheet to describe what's going on, but let me know if you need more details.

Since the complex (and maybe "correct") way has been explained I will cover the second part of your question.

I hate math, I am terrible at mathematical formula in coding. This includes even things as simple as multidimensional arrays. This is why I was drawn to construct 2, with it I don't have to be good at complex programming logic to make some cool things. Now if I was planning on making a heavy loaded mobile game I might worry about efficient process but short of that I go with what works. I have learned a lot about the maths (and even array use) while doing so.

If "I" was making the game you are describing as a Construct 2 owner. I would do it the long hand way because it would be easier for "me" to understand and debug. My game making time is limited so I would rather be making progress than figuring out the correct way or efficient way if it is not needed for this project... by doing this I find I learn a lot of the correct/proper/efficient along the way.

I would make the three recyclable text boxes and a couple of variables for my holders and stats and I would then make a template (ie basically the first interaction with the 3 choices):

Now all I would need to do is copy, paste and change values for 500 events... would only take an hour or two. If you were worried about event sheet length on older mobile devices then you could break your events up over multiple sheets but I would not think that necessary for most adventures.

As for the actual clicking process I would spawn invisible sprites under my text boxes that listened for clicks to determine what was the choice was. You could use long buttons as well that contain the text on them, but you would be limited to the Construct 2 ugly button.

On second look my example is more for narrated story and less randomized adventure. However, I would still follow that line for a randomized text adventure. I would just build more functions for my choices and results.

Anything that occurs often (run, fight, encounters) would be built into functions that i would call as needed.

That is great! Thank you very much @mekonbekon, that is exactly what I needed. I will read a bit on how to use JSON. It does seem more efficient to keep all the data in the same array, with the points for the categories at different depth levels. I will look into how to present the data contained in the array in different layouts, pause the loop to add mini-games and so on, but that seems the best way to approach it.

I see what you mean @chrisfinger. I was going to do the game in a similar way, the one that seems more "intuitive" to me. But I want this project to be easily expanded, so I felt that my way (similar to yours) would be inefficient in the long run. I hadn't thought of the set invisible option, that seems like a good idea for the feedback text box, thank you!

Thanks again for your help, I am making good progress!I was wondering if you knew a way to store images in arrays. For example, imagine the feedback included the text and an image. Could I store the name of the image in another Z layer and somehow call it and have the image appear on the layout?

The easiest way to achieve this would be to have one image sprite and then store all the images as frames on that one sprite.

Give the sprite two animations, one for feedbackA and one for feedbackB, and add the relevant images to those animations: keep the frames in order of the questions.

That way all you need to do is set the frame on the image sprite to the current question and switch the animation depending upon which answer was selected - no need to add extra data to the array, because you're just using the existing data to switch the state of the image sprite.

You could even add an additional animation to show an image before feedback is selected.