set of questions dialog help

Get help using Construct 2

Post » Thu Mar 08, 2012 5:58 am

I'm a bit stuck here. I am trying to make a set of questions with A & B answers After you start a new day and you meet your PolyCom assistant you are suppose to answer a series of questions. The way I am trying to implement it is skipping ahead instead of iterating thru them. all the code for this is on quarters01 event sheet.

here is the Construct 2 file:Starborn capx file
And the demo page:Starborn

If you could show me a good way to accomplish this type of dialog it would really help.Loki20202012-03-08 14:03:03
B
22
S
7
G
3
Posts: 41
Reputation: 2,751

Post » Fri Mar 09, 2012 7:57 pm

Why isn't anyone responding. Did I not present the question well enuff? I know this is not hard for you brilliant peeps.
B
22
S
7
G
3
Posts: 41
Reputation: 2,751

Post » Sat Mar 10, 2012 1:24 am

Nobody is responding probably because nobody wanted to dive into your heavy code. It's not super easy.

Now than I read it a bit, I know that you're not doing it the right way if you want to repeat stuff over and over with more text content.

When you see yourself copying stuff many times to achieve the same kind of display, you should try to find what is common and how to only change what is not.

The things that are common are :
- a text with a question in it
- two possible clickable answers Or a clickable "Next"

In short we can say that the Next is like an answer because in both case you will display the next text

So basically you need 3 text object.
You can either make them 3 instance with an instance variable 'type' to tell them apart (type = "question", type="answer1", type = "anwser2")
Or
Use 3 different object and group them in a family 'dialog'

This way you can make the 3 object appear at the same time and avoid most of the repeated "set visible" lines

Then the only thing you have to care about is how to grab the proper string and put it in the proper text object

That's where it's complicated. If you have a dialog tree like :
[code]Question0
-> answer 0
    -> Question 1
      -> answer 2                    
        -> Question 3
          -> answer 6
            -> [END OF CONVERSATION]
          -> answer 7
            -> [END OF CONVERSATION]
      -> answer 3
          -> [END OF CONVERSATION]
-> answer 1
    -> Question 2
      -> answer 4
          -> [END OF CONVERSATION]
      -> answer 5
          -> [END OF CONVERSATION][/code]
You will need to structure your data in a way that associate each question with its possible answer and each possible answer to the possible next question or end of converstation.
One way to do it is to have two variable, one for question and one for answers
[code]Global text questions = ""
Global text qnswers = ""
+System: on start of layout
-> System: set questions to "Question0|0|1
Question2|2|3
Question3|4|5
Question4|6|7"
-> System: set answers to "answer0|1
answer1|2
answer2|3
answer3|end
answer4|end
answer5|end
answer6|end
answer7|end"[/code]
And then use another global variable to know which question and then which answer to display (I will use the "all text object are instances with variable type to tell them apart" aforementionned option)
You'll also need a 'nextQ' instance variable (type text) for the text object answer. We will store the next question information in it
[code]Global number Qi = 0          //index of the current question
Global text curA=""           //list of current possible answer
System:Qi > 0
Text: type = "question"
    Local text Q = ""        //line which hold the question and its possible answer's index
    -> System: set Q to tokenat(questions,Qi,newline)
    -> Text: set text to tokenat(Q,0,"|")
    -> System: set curA to replace(Q,Text.text&"|","")
System: for "" from 0 to tokenCount(curA,"|")-1
Text: type = "answer"&loopindex+1
    Local number Ai = 0        //current answer index
    Local text A = ""          //line which hold the answer and its associated next question
    -> System: set Ai to int(tokenat(curA,loopindex,"|")
    -> System: set A to tokenat(answers,Ai,newline)
    -> Text: set text to tokenat(A,0,"|")
    -> Text: set nextQ = tokenat(A,1,"|")
Mouse: On click on Text
Text: nextQ not equal to ""
-> set Qi to int(Text.nextQ)
Text:nextQ equal "end"
    -> set Qi to -1[/code]

Should work.
Yann2012-03-10 19:48:59
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Mar 10, 2012 7:20 pm

Thank you for a solution! This is a bit over my head but I will try my best. I hesitate to even ask, but would you whip up a demo capx? And do you think ( particularly with recent interaction with the RPG maker community link ) that this subject warents a tutorial? Thanks again Yann, you do this community a great service and I appreciate it!Loki20202012-03-10 19:28:39
B
22
S
7
G
3
Posts: 41
Reputation: 2,751

Post » Sun Mar 11, 2012 7:59 am

dialogTree.capx
and tuto... hmpf... I'll see
Last edited by Yann on Sun Sep 14, 2014 9:24 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Mar 15, 2012 6:22 pm

Ok, so I was studying your code and had it nearly understood and decide to try and implement it. Much to my dismay, my game is broken before I even get started. For some reason the next button in intro03 and quarters01 is not doing their job any more and locks the 8-dir move of the eye thingie. After a couple hours o trouble shooting I found that it all goes working again if I reverted Construct 2 back to v.79 but now I cant open your capx (insult to injury)lol
any suggestions?
B
22
S
7
G
3
Posts: 41
Reputation: 2,751

Post » Thu Mar 15, 2012 11:02 pm

rename my capx into a .zip and open the caproj file to change the version
and then revert it back to a .capx.
I don't use any new stuff that should work.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: mercuryus and 15 guests