Reference JSON data loaded into Dictionary?

0 favourites
  • 3 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hello,

    I'm working on a Diablo II style skill tree prototype and running into problems loading data from either an XML file or a JSON file. Here's what I am trying to do:

    1) System: On start of layout/Ajax: Request .json project file

    2) Ajax: On load of .json file/Dictionary: Load from JSON string "json project file name"

    3) Mouse: On left click on sprite object/System: Set Global Variable to match Instance Variable on the sprite object.

    4) Have the various text objects load specific lines of data from the JSON data. Below is the JSON data I am loading:

    [{"PowerName":"Heavy Slash","Requirements":"Long Sword","Keywords":"Sword, Long Sword, Technique, Focus Builder, Accurate, Mandatory","Power":"1(W),Special","Type":"Technique","PlusResource":"+1 Focus","MinusResource":"N/A","Target":"Single","Range":"1","Splash":"N/A","Resist":"Physical","Duration":"Instant","Cooldown":"At Will","Description":"Accurate: +5 Precision. Deals 1*Weapon Damage to target. Builds 1 Focus. If caster has no Focus at time of usage, damage is boosted to 1.5*Weapon Damage."}, {"PowerName":"Runthrough","Requirements":"Long Sword","Keywords":"Sword, Long Sword, Technique, Focus Consumer, Accurate, Mandatory","Power":"1(W), +.5(W) per Focus","Type":"Technique","PlusResource":"N/A","MinusResource":"-All Focus","Target":"Single","Range":"1","Splash":"N/A","Resist":"Physical","Duration":"Instant","Cooldown":"At Will","Description":"Requires at least 1 Focus, consumes all Focus. Accurate: +5 Precision. Deals 1*Weapon Damage (plus .5 Weapon Damage per Focus consumed). Reduces the target's Toughness by 10 (plus 2 per Focus consumed) for 2 rounds. Actionless if user has 3 or more Focus."}, {"PowerName":"Defensive Strike","Requirements":"Long Sword","Keywords":"Sword, Long Sword, Technique, Focus Builder, Accurate, Offhand, Actionless, Accurate","Power":"1(W)","Type":"Technique","PlusResource":"+2 Focus","MinusResource":"N/A","Target":"Single","Range":"1","Splash":"N/A","Resist":"Physical","Duration":"1 round","Cooldown":"2 rounds","Description":"Accurate: +5 Precision. Deals 1*Weapon Damage to target. Builds 2 Focus. Boosts Toughness by 10 (plus Sword Proficiency Level) until end of next round."}]

    I am trying to call a specific "PowerName" text (for example, the first one) into a text object.

    You can see how far I've gotten by looking at this this project.

    TL;DR, how do I load up a JSON data file into a dictionary and then call up a specific bit of data from that JSON file?

    Thanks in advance, I am pretty stumped!

    Phil

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The C2 objects that use json are formatted a specific way to get them loaded right, so unfortunately you will have to do the same to your file for it to work.

    You can simply use the download feature, or input your own data into a C2 object, and then download it that way.

    I believe there are plans for some way to parse regular json files.

    Lets just hope its not too far into the future.

  • Do you know of a way to parse XML in the same way. Like referring to the first of a given tab?

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