Just a doubt: Can I use c2 to read these informations?

0 favourites
  • 2 posts
From the Asset Store
Its just different, enjoyable and no doubt worth playing !
  • The project needs to follow the instructions of a json file with this structure:

    Is it possible? is it difficult?

    Please, I need some answer to figure out if I'm capable to do this project or not.

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could look at the json plugin by yann and see if that's something you could work with.

    Alternately you could use the browser object to access the info.

    First step is to get the json data into a variable. Options include:

    * using the Ajax object to get a file added to the project or even from a web address.

    * pasting it into a textbox when you run the game.

    * creating a variable and pasting it as the initial value.

    * using the set variable action and pasting it there. For this one you'll need to first replace all the " with ' and put a pair of quotes around it.

    Ok, so you get the json data with one of those methods and put it in a variable, you then run this action:

    Browser: run js "window.myjson=" & variable

    Then barring any js errors you should be able to access any value in the json with something like:

    Browser.execjs("myjson.presentations[0].name")

    It's just JavaScript so it maybe learning a bit of that could be useful.

    Presentations is an array so the above accesses the first one and gets it's name. At least it should, unless I made some typo.

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