Importing text data

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

    I have just started writing a word puzzle game. The issue that I am facing is that there is no way to import data easily. I have searched the forum but I cannot find anything.

    I need to create an array that will hold a lot of words. How can I do this without having to painstakingly enter the data manually?

    Maybe this could be added to the list of suggested features if there is a demand for it of course.



    EDIT: I know I can use AJAX for the game when hosted on a website but I am interested in developing for Android phones, so I want to include the data in a APK.

  • Perpaps with the FileReader - plugin and a local text-file. Haven't tried it but with the right policies for the app this should work.

    [Edit]Have forgotten the Load JSON-Plugin <img src="smileys/smiley2.gif" border="0" align="middle">

  • Hi Joe7,

    Thanks for the ideas. I don't really want to use a plugin to read a file at run-time. I'd like to insert the data directly into an array. Ideally, I want to store the data in a spreadsheet and create a script that can insert the data into the source code of a C2 game.

    My games rely heavily on data as they are more educational. Inputting data directly in C2 is cumbersome and prone to potential errors (abeit user created). It would be nice to find an easy way to manage this.

  • I think there is a plugin for exactly what you want. Look through them all.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Squidster,

    Thanks for the suggestion. However, as mentioned in my previous post, what I'm really looking for a workaround to directly insert data into a non minified version of the source code.

  • simwhi:

    here's a short example(capx) with arrays in the source-code of the index.html. To call the functions from within C2 I've used the Call Javascript-Plugin. Afaik calling javascript-functions isn't possible without a custom plugin.

    If you really want to insert data directly in the non minified version of the file c2runtime.js - I would recommand write an own plugin. When exporting a project, C2 inserts 'some' sourcecode of all the in the project used plugins in this file.

    Just to mention: I personally would never implement it both possibilites shown above, because

    1) a non minified version brings you no advantages - only the possibility to write messy javascript-code.

    2) a plugin written only for one project isn't very useful for the next projects.

    3) If I would need something like the example above I would write the scripts in an external file - eg "myScriptfile.js"

    4) I've created some quizzes too and I personally prefer loading JSON-datas(per javascript) or anyway with ajax - just to seperate the datas completely from the runtime. That way I win the possibility to reuse the quizzes. The plugin load JSON is a small sideprodukt of a quizz I've made.. <img src="smileys/smiley2.gif" border="0" align="middle">

  • Is there any existing plugin that would read a XML file?

  • simwhi. I believe its possible. Have a look at my tutorial -

    If I have gotten you right you need to have many global variable, array and webstore and if you wont mind please send me your capx so that I can have a deeper look what your saying and try to find a solution.

  • You can read a file in with ajax and do whatever you want with it in the success callback.

    I don't know what limitations the c2 ajax plugin places on this but with regular jquery it's a nonissue as long as the file you're loading is in the same domain.

  • Thanks guys for all your suggestions. What a great community!

    I'm developing my apps for the Android marketplace, so I want to package the data (words in this case) into a single APK file. I'm not sure how to do this other than manually type each word into an array within C2. I don't want to do this as it will be very time consuming. I want to find a way to inject the data into the source code of my game.

    A feature to import a CSV text file directly into C2 arrays would be awesome!

    zaks I will have a look at your tutorial in a day or so. Many thanks.

  • CSV plugin

  • rexrainbow

    How can I import an online hosted csv file from my app installed on my iphone (locally) ?

  • septeven

    Uh, I guess, in C2, you can use AJAX to get (csv) strings then process it (load into csv plugin).

    I might not catch your problem correctly.

  • rexrainbow

    Yes but if the csv file is hosted e.g on my website, and the app is installed on my iphone, there will be a problem cause cross-domain security.

    I've read about the "Access-Control-Allow-Origin: *" but I didn't be able to figure it out...

  • septeven

    Sorry, I have no idea about "cross-domain security". You might ask to

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