What have I done wrong?

0 favourites
  • 8 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • I need help from someone whos eyes have not started to melt from staring at this for too long.

    What have I done wrong here? I want to save a key in local storage using the WebStorage object. But the key is going to be changed every week so I put the key in a text file (.php actually, with just a text in it) on my webserver, so now it will fetch that text file using AJAX when layout has started and add that value into a key with the Dictionary object. Now this is what I've done to save the value from my webserver to a local stored key:

    On Start of layout -> AJAX: Request "address to the file" (tag "AlreadyDone")

    AJAX: On "AlreadyDone" completed -> Dictionary: Add key "AlreadyDone" with value AJAX.LastData

    Variable equal to or greater than 12 -> WebStorage: Set local key "AlreadyDone" to Dictionary.Get("AlreadyDone")

    This is how it's loaded and saved. I have no idea if it's actually saved, which is part of the problem. And to check if my saved key value is the same as the one on the web, I did it like this:

    Webstorage: Local key "AlreadyDone" is Dictionary.Get("AlreadyDone") -> Do stuff...

    WebStorage: Local key "AlreadyDone" is NOT Dictionary.Get("AlreadyDone") -> Do something else.

    It just seems to ignore what I have saved and continue as if my saved value is not the same as on the web, even if it is.

    I'm quite bad at explaining so I hope someone understands me at least..

  • Do you have a server managing this saved file for you? I don't think you can (or should be allowed to) save files on a server or computer using Construct.

    It sounds like your file is not getting saved, and thus you get 'stale' data from what your file actually contains.

    You say you have a webserver (like Apache?), but Apache only delivers content. It does not manage it. You have to build an application of your own (in something like Java, PHP, Python?) to manage the files for you behind the scenes.

  • I only use a normal website-server, meaning I upload a .php file with the content "hello" for example and fetch that file with ajax.

    This way I can change the content of the text files really easy

  • You can use server-side PHP to read/write files on the server (I believe -- I am a Java-nut myself).

    I would look into re-writing that data file on your webserver using PHP.

    http://davidwalsh.name/basic-php-file-h ... ose-delete

    Like have some kind of data schema for your file (which it sounds like you do already), open the file, hunt down the exact line that needs to be changed, change it, and rewrite the new file.

    This might bog your server down if you do this a lot though.

  • Well it's not the catching of my file that's the problem, I have several more files that's catched without problems. So I think you misunderstood my post (don't blame you, horrible at explaining things)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sorry.. misread..

  • What does "catched" mean in your context? Sorry, I make assumptions in order to draw meaning from missing information.

  • That I have requested the file with AJAX and it went successfully. IE; the file has been catched

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