set of questions dialog help

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

  • Why isn't anyone responding. Did I not present the question well enuff? I know this is not hard for you brilliant peeps.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 :

    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]

    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

    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"

    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

    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

    Should work.

  • 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!

  • dialogTree.capx

    and tuto... hmpf... I'll see

  • 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?

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)