Simple Dialogue tree

This forum is currently in read-only mode.
From the Asset Store
Create complex dialogues with ease with this tool/template!
  • Hi,

    Currently i'am trying to script a simple dialogue tree. I know there is an example for dialogues using hash tables and text files but i want so write it down from scratch to understand the machanics.

    Basically it should be simple, but i can't get it to work, maybe someone of you can give me a hint what i'am doing wrong.

    Its starts with a simple message, the player can choose between two options (Yes/No). If the player klicks on the yes button i change a private variable of the button to 1(lets name it ChoiceA) and displays a second message, again with two options.

    The "Yes" button is now set to ChoiceA=1. I include a condition to check if ChoiceA equals 1, and if this condition is true and the "Yes" button is clicked again, a third message should appear.

    But my problem is, that if i click on the Button during the first message, the programm jumps automatically to the third message. So the second message never got displayed.

    Anyone of you have a idea what i'am doing wrong?

  • Hi. It's really difficult to pinpoint these types of problems without being able to see the events, but I'll throw a couple of ideas out...

    It sounds as if the logic is flawed. Go through the events, thinking of them in sort of a flowchart way, and see if whatever state variables/conditions you're using actually keep the state from advancing to the next step until the proper user input is had. For instance, if you used a variable to temporarily signal a transition, then you'd usually need to set it back to zero/off upon that transition, so that it won't go to the next immediately.

    Also, make sure that you are using a 'button clicked' condition, and not a 'button down' condition. That's a common mistake.

    Not sure what else may cause your problem.

  • I would postes my events, but i can't post attachments in this forums. So i can't even post a screenshot.

    But my events are really simple, there are only 3 of them:

    1: On clicked Button:

      a.Write Text b. Button.Set"ChoiceA" to 0

    2. On clicked Button:

    Value "ChoiceA" equal to 0

      a.Write second Text b.Button.Set"ChoiceA" to 1

    3. On clicked Button:

    Value"ChoiceA" equal to 1

      a.Write third Text

    Thats all. I tested if reseting the private variable to 0 does anything, like you suggested, but unfortunately there was no effect.

    I see the problem. The programm executes all variable actions at one click. The message get displayed but only for a few milliseconds and then construct proceeds to the last one. The event chain does not wait for an input. It changes the variables on the first click on the button. I don't know why cause as you can see i told the program to change the value AFTER each click on the button.

  • When you click the mouse, the condition 'if mouse has been clicked' remains true for the whole event sheet until the next tick, not just for the first event that uses it. The simplest ways to fix it are to either order those events backwards or set a variable mouse clicked to 1 and check the variable in each event, like:

    1: On clicked Button:

    variable 'mouseclicked' = 0

    a.Write Text

    b. Button.Set"ChoiceA" to 0

    c. set variable 'mouseclicked' to 1

    2. On clicked Button:

    variable 'mouseclicked' = 0

    Value "ChoiceA" equal to 0

    a.Write second Text

    b.Button.Set"ChoiceA" to 1

    c. set variable 'mouseclicked' to 1

    3. On clicked Button:

    variable 'mouseclicked' = 0

    Value"ChoiceA" equal to 1

    a.Write third Text

    b. set variable 'mouseclicked' to 1

    Then set the mouse clicked variable to 0 at the end of the event sheet.

  • Hi. 'On a certain button clicked' type events will be true throughout the event sheet for the tick that it is true for that button, so all of those will execute in order.

    Arranging them like so should work, assuming that 'ChoiceA' is zero by default:

    On clicked Button:
          Value "ChoiceA" equal to 0
                a.Write Text
                b. Button.Set"ChoiceA" to 1
          Else
          Value "ChoiceA" equal to 1
                a.Write second Text
                b.Button.Set"ChoiceA" to 2
          Else
          Value"ChoiceA" equal to 2
                a.Write third Text[/code:11fyr41t]
    
    Then you may need to reset 'ChoiceA' to zero or something that doesn't apply to those conditions, afterward, depending upon your needs.
    
    All of the 'ChoiceA' tests are sub-events of the 'clicked button' event, and the Else conditions make sure that only one is true per tick.
    
    Tulamide made a nice tutorial on that subject a while back: [url=http://www.scirra.com/forum/viewtopic.php?f=8&t=6880]Introduction to branching[/url].
    
    That may help clear up the event logic for you.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the help!

    Both systems work and i'am sure i can use this knowledge in some advanced scripts.

    I never thought that even branching that seems so easy and simple like this example can become complicated

    I'am a bit ashamed of my self that i could not figure it out by my self. The "If - Else" script reminds me heavily on the old text rpg's i used to write in Qbasic ages ago

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