How do I run C3 code using JSON comparison?

0 favourites
  • 3 posts
From the Asset Store
Run Vovan Run
$1.60 USD
60% off
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello,

    I bought this really cool dialogue system for Construct 3.

    What I am trying to do is run a C3 block of code when certain line executed in the dialogue system.

    Basically, I am trying to execute a C3 block of code once the last line array of "dialogue" is shown using the "JSON compare value" attempting to compare it's "id" within the "dialogue" nested array. I looked at the JSON documentation online on how to execute this. Unfortunately, it is not working. Is there something I am doing wrong or I am missing?

    JSON file code:

    	{
    	"scene": [
    		{
    			"id": 0,
    			"dialogue": [
    				{
    					"id": 0,
    					"char": "npc0",
    					"voice": "",
    					"line": "This is scene 0."
    				},
    				{
    					"id": 1,
    					"char": "npc0",
    					"voice": "",
    					"line": "Here is a 2nd line."
    				},
    				{
    					"id": 2,
    					"char": "npc0",
    					"voice": "",
    					"line": "Here is a 3nd line."
    				}
    			]
    		}
    	]
    }
    

    C3 code block:

    Any Help is appreciated.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First, you are missing ".0" in the path, the correct path is "scene.0.dialogue.2.id"

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

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

    But without seeing the code of that dialogue system it's impossible to tell how it works and when the line is actually "executed". There's probably some event that extracts the ".line" value from JSON and displays it on the screen. So you can try adding a sub-event there that will check if the current JSON path is "scene.0.dialogue.2" and if ".id" key equals 2.

    .

    I have a similar dialogue system, where I added a "function" key in JSON. So when a dialogue line is shown, if "function" key exists for it, the function with that name is automatically called.

  • Thank you for your response dop2000.

    I understand it's hard to give an accurate solution without seeing the full dialogue engine.

    However, your response and the C3 attachment has gotten close to a potential solution.

    Thank you.

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