How do I swap X and Y in an array most effectively? (Setting row to X)

  • I've been migrating my app from C2 to C3. It is heavily dependent on an array as there are about 320 references to it in the event sheet.

    I've been using the CSVToArray plugin to load the array (using the "Row as X" feature), which I need to ditch in order to use C3 runtime. The new array editor is great and will be much better, but I need to flip the X and Y axis at runtime from what is entered in the view, for major ease of use purposes (and so the array editor and debug array listing are consistent).

    I'd rather not edit 320 events (they assume row as X) and I don't want to load the array and then swap it out at runtime with a loop to change the axis. If I look at the available expressions, I don't see how to load the json into the array using x as the row (swapping X and Y).

    Anyone know of a good solution not mentioned above to swap X and Y when the json is loaded into the array? What I'm currently debating is using regular expressions to change the 320 events in a text editor.

    Thanks!

    -Steve

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can load this array into Excel, rotate the table and save to JSON. Or save to CSV and then convert to JSON using any online converter.

    You can probably even do this without Excel, using only free online tools. Convert JSON to CSV -> transpose CSV -> convert CVS to JSON -> load JSON back to C3.

  • I do use Excel to generate the data to begin with. I did not consider that Excel could save to JSON in a format that C3 would recognize. I shall try that next. Thank you.

  • I don't know if you can save to JSON directly from Excel, but you can definitely save to CSV and convert to JSON using online tools. Also, you may need to manually edit JSON header after that. (C2 had a different JSON format, I'm not sure about C3)

  • Cool. I used an online CSV -> JSON tool before but resolved to just getting the array editor to work after fiddling with it too much to get the right format. Should have stuck with it. I suppose I can just do an ajax JSON download of the current functioning array during runtime, verify the format there and use that as a workaround until I can modify the code. Thanks for the guidance and helping me get out of my own head on this. Will go the JSON route!

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