Json dialogue tutorial help- Please

0 favourites
  • 7 posts
From the Asset Store
Create complex dialogues with ease with this tool/template!
  • Hi folks, frustrated newbie game-dev here.

    After spending several hours painstakingly following the Json dialogue tutorial, I've gotten everything in, modified what little I needed to for my assets, and have so far gotten exactly none of it to work.

    I followed along as best I could, with one exception- being a local variable not allowing itself to be used twice, or named the same; I don't actually know which, or how they did it in the example. Barring that, everything appears to be in order.

    Yet nothing save my debug text shows up!

    I do not know why. Please, can someone give me some ideas as to why this is not working? I am at my wits' end here.

    1drv.ms/u/s!AihEKVEcOS6Jhf4ghCza-wfzQisj_Q

  • There are so many mistakes, I managed to get it working, but just barely..

    1. Events 9 1nd 13 and local variables need to be inside the functions as sub-events, not outside.

    2. You are composing JSON path wrong.

    "Scene"& curScene & "Dialogue" will result in "Scene0Dialogue", which is an invalid path.

    Check out this project, it shows paths to all values and keys in JSON:

    dropbox.com/s/srgf9lme08by9wa/JSON-RecursiveRead.c3p

    Besides, you spell key names differently in every event! In one event it's "dialogues", in another "Dialogue". Double-check the spelling in all events. And JSON keys are case-sensitive!

    3. Parallax on the dialogue layer should be 0x0

    Also use layer names in events, not numbers.

  • Thanks for that. I thought I had double-checked everything before I made the copy, fixing the dialogues spelling and ensuring parralax was 0,0 on my layer for said dialogues. I copied lots over from the official tutorial, where everything is dialogues for some reason. Apologies.

    Local variables inside events is something I was unaware was necessary, nor did the tutorial I was using mention this. The JSON path is also straight from the tutorial, so I am doubly annoyed that it's wrong there too.

    Layer names in the events were always red, so I went with numbers since the software itself says you can use them- is that not the case?

    I admit, I am not a huge fan of the way many tutorials I've found are flawed in some way, especially ones I spent hours fighting with.

    Appreciate your help fellow Construct user.

  • Local variables inside events is something I was unaware was necessary, nor did the tutorial I was using mention this. The JSON path is also straight from the tutorial, so I am doubly annoyed that it's wrong there too.

    In this case the local variable needs to be inside the function, otherwise two functions will be changing it and the result may be incorrect.

    Also I think (Variable-1) as a return result is wrong, it needs to be just Variable.

    By the way, you can use JSON.ArraySize("Scene") expression instead of those functions. This will return the number of records in the "Scene" array in JSON.

    Same for the number of dialogues:

    JSON.ArraySize("Scene."& curScene & ".Dialogue")

    Layer names in the events were always red, so I went with numbers since the software itself says you can use them- is that not the case?

    Layer name as any other strings in events needs to be in double quotation marks:

    Set layer "Dialogue" visible

    If you decide to add a new layer tomorrow, you will have to update layer numbers throughout your code. With layer names you won't have this problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Handy stuff in there, thanks! I'll give it a shot today.

    I'm a little confused as to why the tutorial contains so much outdated info, without getting updated- but ah well.

    I am also still confused on the Array size expression you mention. I currently don't have an array in use, just a Json- and I don't really understand where I'm supposed to put what information. Using it as another condition just breaks what little I already had working, and trying to put it in as an action gives me X,y,z options- none of which look right.

    In general, I'm just lost.

  • I am also still confused on the Array size expression you mention. I currently don't have an array in use, just a Json

    Your JSON string actually contains arrays. "Scene" is an array, and "dialogues" is an array. If you see square brackets in JSON string - that's an array.

    So JSON.ArraySize("Scene.0.dialogues") for example will return the number of elements in "dialogues" array in the first scene.

    I suggest you read/watch some tutorials about JSON. It's not that complex and once you understand its structure, it will all make sense.

  • Keep trying to solve it and you'll learn a lot, solving bugs and errors are good possibilities to get a deeper understanding of the software. Keep it up✌️

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