How do I - AJAX/Dictionary/LocalStorage/Array

0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi guys and gals,

    It's been a long while since I've posted here on the boards, so I hope all of you are doing well.

    I have recently picked up C2 again to see how far it has come (I was a CC addict) once more, with intent on making some slightly, non-standard production to help out a friend.

    The main requirement for this project is data handling (storage and recovery) since a portion of the software will be keeping information (text/images) that need to be run-time creatable/editable, then be able to save and commit changes to disk and later recall them easily.

    I have been reading up on the new data objects such as Dictionary, LocalStorage, and the good ole Array... as well as AJAX. Like the noob that I am, I've gotten stuck with a few things. Even tutorials various people have created have left me with unanswered questions, and some of the methods that are used in the tutorials don't seem to function any more (I guess mostly due to depreciated methods and objects).

    --------------

    I have so far successfully managed to pull text data from sevel editable textbox objects and produce a JSON string from the data. I am falling over when it comes to "saving" the data, since there is only the "download" function that requires user input to path the data to a certain location (and no way to point to that same location for re-opening). It really makes me miss the way array saving/loading to plain text used to work in CC, and wonder further why this option has been removed in C2?

    I then began to look at AJAX, for perhaps uploading the JSON data to cloud storage, then retrieving it when requested... but I think I'm doing something wrong (obviously, this is me we're talking about).

    In a nutshell, what would anyone recommend for being able to store data entered in several textbox objects, display this data in a list of some sort (so you can click on it and edit/view the attached data), and obviously recall the data into the same textboxes where it was originally entered for editing/viewing purposes?

    So far I have a dictionary object, and 4 text boxes that generate a JSON string which can be "downloaded". Is there a way to either commit these strings to a local storage (specified drive and directory, NOT web/storage folder in the browser!) or to use AJAX and upload them to say, DropBox, and reliably recall them later?

    Thanks in advance... not using this software for such a long time hasn't made this any easier... but any help or general information would be greatly appreciated.

    ~Sol

  • So it seems, like usual "me" fashion... I should be really looking at NW.js options for data control, since that's going to suit what I want to do far more easily I believe.

    Thanks to Kyatric for pointing this out to me in our skype conversation.

    If anyone however, still has input or information regarding my above methods... I am still interested in seeing what options are available, as in, what is possible and what isn't. Having the data stored on a cloud service would be beneficial, but it's not critical... so NW.js may be just the solution I was after the entire time.

    ~Sol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Long time no see - welcome back! How are things?

    C2 is first and foremost based on HTML5, which means no direct reading/writing to disk. (Imagine if any website you visited could start reading and writing random files on disk!) Local Storage is a pretty recent addition that uses modern browser storage features. You can basically save text to disk, but the browser decides where to save it, so you don't specify any path or filename.

    The easiest solution is: just store everything in the Dictionary object, but when you want to save it to disk, use Local Storage to save the Dictionary JSON data. To load it just read the same Local Storage key and load the resulting JSON string in to Dictionary.

  • Hi Ashley, yes long time indeed! Too long in fact...

    I have decided to take the NW.JS route, as it's going to perform in a manner that will be more suited to the idea that I'm working on.

    The main issue I have with using localstorage, for this project, is that localstorage is limited and also not easily backed-up and re-distributed. The software I'm attempting to build will be for a Point of Sale (POS) system... so having complete control over data amounts and placement into folders is going to be paramount. Kinda makes me miss the old CC, but really loving the new additions to C2. You guys have come a long way, and it's just getting better!

    One question I do have related to this however... is if there are any plans or perhaps known existing plugins that would allow for a file listing (like the listbox objects from VB for example). Essentially a cross between a textbox and a combobox that I could reference individual lines, and/or interface with the individual lines via mouse input? So far it looks like I will have to build something out of dynamically created and assigned text fields and text boxes... which is going to get really messy, really fast.

    I guess being out of the loop for so long has come back to burn me!

    *EDIT*

    After looking around for a while, reading a few things and just taking a browse through the plugins section... I found this:

    Gonna check it out and see if it does the job. If so, some sort of form control illustrated in the example would be awesome to have as a more official addition to C2.

    ~Sol

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