How do I have more than one item at LocalStorage?

Get help using Construct 2

Post » Mon Jun 15, 2015 8:36 am

Hello, great C2 pros!

I want to know how to handle more than one item at LocalStorage. I've read a tutorial by AndreasR, but there is only one item exist at LocalStorage. What should I do if I need more items?

.capx included - http://arte-code.com/temp/GD/LStest1.capx
B
9
S
2
G
1
Posts: 36
Reputation: 712

Post » Mon Jun 15, 2015 10:15 am

You only need to set another name for each item that you want to save. So you set another localstorage with another name with another value. :) Then if you want to do something with that localstorage, you only need to insert the name of the right localstorage in the command.
I hope that helps :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Mon Jun 15, 2015 10:32 am

Thank you so much, aquadijoib!
It's so unexpected that one LocalStorage can store only one item )
Thank you again!
B
9
S
2
G
1
Posts: 36
Reputation: 712

Post » Mon Jun 15, 2015 10:53 am

what you mean by LocalStorage can store only one item?

https://app.box.com/localstorage
Image
B
65
S
23
G
7
Posts: 1,503
Reputation: 10,892

Post » Mon Jun 15, 2015 11:21 am

You also can store something like this:
Code: Select all
{"name":"de","type":"JLoc","langs":["de-DE","en-GB"],"groups":{"MainMenue":["Home","Registration","LostPassword","MailVerification"],"Login":["LoginName","Password","LoginBTN","BackBTN"],"Registration":["LoginName","Password","Password2","Email","Email2","RegistrationBTN","BackBTN"],"Recover":["Email","SendBTN","BackBTN","CodeBTN","Code","Password"],"MailVerification":["Code","SendBTN","BackBTN","CodeBTN"],"ReMailCode":["SendBTN","BackBTN","Email"],"Charselect":["LoginBTN","CreateBTN","DeleteBTN","LogoutBTN"],"Charcreate":["Name","Order","HairColor","Gender","CreateBTN","BackBTN"],"MainInfo":["Titel"],"Base":["BackBTN","SendBTN"]},"data":{"de-DE":{"MainMenue":{"Home":"Login","Registration":"Registrieren","LostPassword":"Passwort vergessen","MailVerification":"Mail Verifizierung"},"Login":{"LoginName":"Login Name","Password":"Passwort","LoginBTN":"Login","BackBTN":"Zurück"},"Registration":{"LoginName":"Benutzername","Password":"Passwort","Password2":"Passwort Wiederholung","Email":"Email","Email2":"Email Wiederholung","RegistrationBTN":"Registrieren","BackBTN":"Zurück"},"Recover":{"Email":"Email:","SendBTN":"Senden","BackBTN":"Zurück","CodeBTN":"Zur Code Eingabe","Code":"Code:","Password":"Passwort:"},"MailVerification":{"Code":"Code:","SendBTN":"Senden","BackBTN":"Zurück","CodeBTN":"Code Anfordern"},"ReMailCode":{"SendBTN":"Senden","BackBTN":"Zurück","Email":"Email:"},"Charselect":{"LoginBTN":"Login","CreateBTN":"Character erstellen","DeleteBTN":"Character löschen","LogoutBTN":"Ausloggen"},"Charcreate":{"Name":"Vor und Zuname","Order":"Orden","HairColor":"Haarfarbe","Gender":"Geschlecht","CreateBTN":"Erstellen","BackBTN":"Zurück"},"MainInfo":{"Titel":"Information"},"Base":{"BackBTN":"Zurück","SendBTN":"Senden"}},"en-GB":{"MainMenue":{"Home":"Login","Registration":"Registration","LostPassword":"Lost Password","MailVerification":"Mail Verification"},"Login":{"LoginName":"Login Name","Password":"Password","LoginBTN":"Login","BackBTN":"Back"},"Registration":{"LoginName":"User Name","Password":"Password","Password2":"Repeat Password","Email":"Email","Email2":"Repeat Email","RegistrationBTN":"Register","BackBTN":"Back"},"Recover":{"Email":"Email:","SendBTN":"Send","BackBTN":"Back","CodeBTN":"Enter Code","Code":"Code:","Password":"Password:"},"MailVerification":{"Code":"Code:","SendBTN":"Send","BackBTN":"Back","CodeBTN":"Get Code"},"ReMailCode":{"SendBTN":"Send","BackBTN":"Back","Email":"Email:"},"Charselect":{"LoginBTN":"Login","CreateBTN":"Create","DeleteBTN":"Delte Character","LogoutBTN":"Logout"},"Charcreate":{"Name":"First and Lastname","Order":"Order","HairColor":"Hair Color","Gender":"Gender","CreateBTN":"Create","BackBTN":"Back"},"MainInfo":{"Titel":"Information"},"Base":{"BackBTN":"Back","SendBTN":"Send"}}}}


This really a lot! :lol:
Json is best :!:
Last edited by deathangel1479 on Mon Jun 15, 2015 1:10 pm, edited 2 times in total.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Post » Mon Jun 15, 2015 1:03 pm

Wow, people, you're never ceasing to amaze me!

Thank you again, but at korbaach's example is actually one item (if I understood correctly), he's just making string concatenation, and the result is set as a "date2" LocalStorage item.
B
9
S
2
G
1
Posts: 36
Reputation: 712

Post » Mon Jun 15, 2015 7:42 pm

@Kirya
You could save much data in one LocalStorage if you seperate it later with the mid(text,index,count) command. Text is where you get the value from.
index is when you have "10 20" as value then if the index is 1 it means the 10. Then count means how many characters you want to get.
Example:
Value from LocalKey (Key): "Hello World"
Seperate it and put that in Variable2:
Variable2-> Set Value-> mid(WebStorage.LocalValue(Key),2,5)
With that code the LocalKey: Key will be seperated and the word World will be put in the Variable2.
I hope I could help a little :D
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Tue Jun 16, 2015 4:38 am

Thank you again, @aquadijoib !
Now I've got it ^_^

I wonder why Scirra team left so many complexities in a program designed to be an easy tool for non-programmers ^___^ Anyway, Construct2 is a great tool!
B
9
S
2
G
1
Posts: 36
Reputation: 712

Post » Tue Jun 16, 2015 6:04 am

deathangel1479 wrote:You also can store something like this:
Code: Select all
{"name":"de","type":"JLoc","langs":["de-DE","en-GB"],"groups":{"MainMenue":["Home","Registration","LostPassword","MailVerification"],"Login":["LoginName","Password","LoginBTN","BackBTN"],"Registration":["LoginName","Password","Password2","Email","Email2","RegistrationBTN","BackBTN"],"Recover":["Email","SendBTN","BackBTN","CodeBTN","Code","Password"],"MailVerification":["Code","SendBTN","BackBTN","CodeBTN"],"ReMailCode":["SendBTN","BackBTN","Email"],"Charselect":["LoginBTN","CreateBTN","DeleteBTN","LogoutBTN"],"Charcreate":["Name","Order","HairColor","Gender","CreateBTN","BackBTN"],"MainInfo":["Titel"],"Base":["BackBTN","SendBTN"]},"data":{"de-DE":{"MainMenue":{"Home":"Login","Registration":"Registrieren","LostPassword":"Passwort vergessen","MailVerification":"Mail Verifizierung"},"Login":{"LoginName":"Login Name","Password":"Passwort","LoginBTN":"Login","BackBTN":"Zurück"},"Registration":{"LoginName":"Benutzername","Password":"Passwort","Password2":"Passwort Wiederholung","Email":"Email","Email2":"Email Wiederholung","RegistrationBTN":"Registrieren","BackBTN":"Zurück"},"Recover":{"Email":"Email:","SendBTN":"Senden","BackBTN":"Zurück","CodeBTN":"Zur Code Eingabe","Code":"Code:","Password":"Passwort:"},"MailVerification":{"Code":"Code:","SendBTN":"Senden","BackBTN":"Zurück","CodeBTN":"Code Anfordern"},"ReMailCode":{"SendBTN":"Senden","BackBTN":"Zurück","Email":"Email:"},"Charselect":{"LoginBTN":"Login","CreateBTN":"Character erstellen","DeleteBTN":"Character löschen","LogoutBTN":"Ausloggen"},"Charcreate":{"Name":"Vor und Zuname","Order":"Orden","HairColor":"Haarfarbe","Gender":"Geschlecht","CreateBTN":"Erstellen","BackBTN":"Zurück"},"MainInfo":{"Titel":"Information"},"Base":{"BackBTN":"Zurück","SendBTN":"Senden"}},"en-GB":{"MainMenue":{"Home":"Login","Registration":"Registration","LostPassword":"Lost Password","MailVerification":"Mail Verification"},"Login":{"LoginName":"Login Name","Password":"Password","LoginBTN":"Login","BackBTN":"Back"},"Registration":{"LoginName":"User Name","Password":"Password","Password2":"Repeat Password","Email":"Email","Email2":"Repeat Email","RegistrationBTN":"Register","BackBTN":"Back"},"Recover":{"Email":"Email:","SendBTN":"Send","BackBTN":"Back","CodeBTN":"Enter Code","Code":"Code:","Password":"Password:"},"MailVerification":{"Code":"Code:","SendBTN":"Send","BackBTN":"Back","CodeBTN":"Get Code"},"ReMailCode":{"SendBTN":"Send","BackBTN":"Back","Email":"Email:"},"Charselect":{"LoginBTN":"Login","CreateBTN":"Create","DeleteBTN":"Delte Character","LogoutBTN":"Logout"},"Charcreate":{"Name":"First and Lastname","Order":"Order","HairColor":"Hair Color","Gender":"Gender","CreateBTN":"Create","BackBTN":"Back"},"MainInfo":{"Titel":"Information"},"Base":{"BackBTN":"Back","SendBTN":"Send"}}}}


This really a lot! :lol:
Json is best :!:

Other good tip! Thanks for helping those people, @deathangel1479
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
24
S
7
G
4
Posts: 326
Reputation: 3,878


Return to How do I....?

Who is online

Users browsing this forum: David181, luckyrawatlucky and 2 guests