How do I have more than one item at LocalStorage?

0 favourites
  • 9 posts
From the Asset Store
Unlock platyers earning coins, and save it with Localstorage
  • 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

  • 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

  • Thank you so much, aquadijoib!

    It's so unexpected that one LocalStorage can store only one item )

    Thank you again!

  • what you mean by LocalStorage can store only one item?

    https://app.box.com/localstorage

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You also can store something like this:

    {"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"}}}}[/code:2g608zz9]
    
    This really a lot!  
    Json is best
  • 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.

  • 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

  • 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!

  • You also can store something like this:

    {"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"}}}}[/code:1mmz2ghl]
    
    This really a lot!  
    Json is best  
    

    Other good tip! Thanks for helping those people, deathangel1479

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