>
> https://i.imgur.com/MEVWcPs.png
>
> I am using the same sample JSON file as you. But when I run the layout, I get the DebugText changed to "00" only. So I am not sure what does this do and what am I getting even since the JSON has no 0s.
The path you are using is not correct
JSON2.get(".recipes" & loopindex) probably will work
It depends on the content of your json file though.
Interesting. Thank you for pointing that out. Does this mean that the parent "JSON part" (like the parent header) must have a "." before it? I thought it didn't need that, since it is at the very top.
You might want to check back on the JSON example provided with Construct, it is pretty simple to understand how you are supposed to create your structure.
https://editor.construct.net/#open=json
Oh, I did. I looked at that for hours really, but it doesn't help in understanding how to divide a JSON and search based on sub-sub entries with a list. I wish there were more advanced examples that go in depth of how to use JSON and XML.
And check back on the example provided by Laura, it should make more sense.
The issue here doesn't seem to be with scripting or events, but with the actual structure of your JSON file.
Post it, it will be easier to establish the correct events in regards to how you established your file.
In my experience XML is not simpler.
The JSON is fine, I posted it before here:
https://www.construct.net/en/forum/construct-3/how-do-i-8/best-data-structure-crafting-154650#forumPost1020452
I think you used it in the example .c3p you worked with Laura on. I've also used it to print out the information inside and it worked. Now the structure may not be C3's "optimum one" (if there is such a thing) but I use JSON validator when I write JSON since I personally can't write it properly without one :D.
Thought I'd have a go at this.
The events simplify nicely by having a dictionary for the inventory and an instance of a recipe dictionary for each recipe.
https://www.dropbox.com/s/cw1xuiiymjqq6oq/crafting_test2.capx?dl=1
JSON and XML are a pain to write imo. With the above example you can just create the recipes with events fairly cleanly, or just load and parse a plain text file to populate it.
#recipe Blinding Flash Potion
2 wormwood
5 sulfer
#recipe Potion of Sweet and Savory
5 salt
5 sugar
I could get behind writing recipes like that all day long. No quotes or matching brackets.
Thank you very much for trying this. I am using a similar approach at the moment (conceptually); I have a dictionary file for every recipe and one dictionary object that I load the file into the dictionary, check if it is this one or not. If it is not, I move to the next file. Which gets rather hectic fast events wise. This is interesting though. Could I ask you to ELI5 this part please?
https://i.imgur.com/pt88uw6.png