Import and Export a text file

0 favourites
  • 6 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • I've been searching and trying to figure out how to do this properly for over an hour now to no avail, hopefully there are some smart cookies on here who can help.

    All I'm wanting is for my project to import and export a simple text file. For example the file may look like this

    Monster

    2

    Coin

    23

    Cat

    3

    And when I click a button, it will import those numbers into the C2 file and I can then add or subtract and then send the numbers back to the same file they came from.

    Any help is appreciated, and if possible, I'd like to not have to use a plug-in <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Is your text file online? If yes, then use the AJAX OBJECT to read (get) the file and to write (post) in it.

  • Interactions with the filesystem are very limited browser-side. I don't think there is any way to write directly into a file with no download dialog and what not...   <img src="smileys/smiley18.gif" border="0" align="middle" />

  • Ideally the file would not be online, but could put it online if it has to be.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the file could be online - AJAX and a small PHP script on your server should menage your save/load needs. This could be the difficult part, because you have to check many possible incoming and outgoing information cases.

    If you would like to keep it locally, maybe the cookie plugin is exactly what you need:

    http://www.scirra.com/forum/plugin-Cookies_topic51805.html

    I don't think there is another C2 easy workaround way to use a local file from within your browser.

  • Project files for everything that is loading from a file, but I don't think you can modify its content from your game.

    You may also want to check out webstorage and the score example I give in this tutorial which pretty much allows you to put a default set of datas on your clients computer and "play" with it.

    I'd recommend it over a third part plugin as it is built-in.

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