What have I done wrong?

Get help using Construct 2

Post » Fri May 15, 2015 5:45 pm

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..
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Fri May 15, 2015 5:51 pm

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.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Fri May 15, 2015 5:54 pm

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
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Fri May 15, 2015 6:02 pm

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.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Fri May 15, 2015 7:21 pm

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)
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Fri May 15, 2015 7:34 pm

sorry.. misread..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 10:10 pm

What does "catched" mean in your context? Sorry, I make assumptions in order to draw meaning from missing information.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Sat May 16, 2015 1:42 pm

That I have requested the file with AJAX and it went successfully. IE; the file has been catched ;)
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests