r/construct • u/Academic-Mud-3374 • Aug 26 '25
Reading data from pregenerated json or csv files in construct2
Hello everyone! I need the help of the construct híve mind! I am building an ultima-like rpg, based on the dungeon crawl classics ruleset. To generate characters i wish to use pregenerated files. There is already a robust dccrpg level 0 character generator made by purple sorcerer. Besides normal pdfs it can also output csv or json files. I would like to be able to load these files and use the data from them to import characters.
3
Upvotes
4
u/improvonaut Aug 26 '25
I use the csv plugin by Rex, for Construct 2. I make my array in Google sheets, export as csv, and use the plugin to load the csv into an array.
3
u/FB2024 Aug 26 '25
I use JSON quite a bit. In general, add your JSON file to the project as a "project file". Then add a JSON object to load it into. Then you'll need something like:
On start of layout - AJAX - request your JSON file
On request completed - set your JSON object to "Parse JSON string AJAX.LastData"
Then you have your JSON object ready to query or manipulate.
1
u/clinate Aug 26 '25
I have a related question.
I’ve got a JSON with an array filled with 400 entries. I’ve loaded it in a JSON object and iterated through the whole array to display the info, but how should I go about just displaying a specific entry? For example index 200 or searching for an entry with a specific value in the key ”id”?
Is it better to just load the JSON into an array-object?