How do I fill an array with an XML file

0 favourites
  • 10 posts
From the Asset Store
An educational game for Fill in the Blanks. An easy to use template for developers to build larger games
  • Hi, I think the question is quite simple but I haven't found a convincing answer in the manual...

    I'm working on a procedural generation for a rogue-like game. I'm looking for a simple way to have rooms' presets (or assests). So I'm the generation of my world I would just have to load theses assests to create my rooms...

    If you have another idea of a simpler way to make it, i would be glad to hear it.

    Sorry for my clumsy english, I'm not fluent.

  • How is your xml and array arranged? What do you want to load into your array?

    To parse a project file, you will need to request it with AJAX. Then On AJAX completed, you will have access to the contents in AJAX.LastData.

    You can use tokenat or the XML object to pull out whatever relevant information you want to put into an array however you want or into any other data structure.

  • I want my array to contain the tileset of my rooms, entity's and objects' positons.

    I just want to know how can I create an array-like object with an XML file.

    Also, I already know a bit about AJAX and XML files, i've made a dialogue system by myself

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahhh I see.

    I'm not very familiar with XML myself, so someone else may be able to give better input.

    I think the structure of an XML file generally lends itself to describing nested data rather than a spreadsheet like array. It would be more like an object and its instance variables. For an array, it may be better to use a spreadsheet saved as a .csv.

    You also mentioned procedural generation, so wouldn't your array be generated in game? In that case, you can simply save your arrays as JSON, and load that straight back into your array. No need for XML.

  • ok I'm not familiar with spreadsheet and JSON I will take a closer look in the manual.

    But you're right my arrays aren't generated in game.

  • Ok...

    I Undertsand how JSON files are structured but I didn't find: where can i load a value from a Json file?

  • If you are familiar with XML, then you know how to read value's from the XML. For that you have the XML plugin.

    Subscribe to Construct videos now

    Now you just have to write them one by one in the array. During runtime, yes, that is wat coding is.

    I suppose you need to alter the value's. If you just and only need to read, then there is no need to parse them in an array ?

  • Thank you but I think XML is indapted to create and manage an array with the tileset of my rooms.

    I've found a plugin to use JSON file.

    I'm now looking for a way to associate the value in my JSON array to the equivalant location inside my C2 array.

    Fianally i see what you're saying but I need to create a C2 array.

  • Thank you, This is exactly what i was looking for!

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