Discuss Scratch
- Discussion Forums
- » Developing Scratch Extensions
- » LocalStorage Variables Extension
- JGames101
- Scratcher
100+ posts
LocalStorage Variables Extension
What Does it Do?
My LocalStorage Extension adds two new blocks:
This is really good in cases where you want to save user data. Usually, you would do that with Cloud Data. But that's slow and inefficient, especially when you have a lot of players. LocalStorage is useful in that case, because you can store everything you want to on the player's device.
I've Seen This Before.
There is another localStorage Extension, but it only allows you to use one variable. This one allows you to create as many as you would like.
Try it Out
Try it in ScratchX
Code
Thank you!
If you like this extension, check out my previous one, Desktop Notifications.
My LocalStorage Extension adds two new blocks:
[highscore] :: reporter extensionThese act just like the variables in Scratch, but they have one big difference: Unlike Scratch variables, they don't go away when the page is closed or reloaded. They stay as long as the player and the creator want.
set [highscore] to [12] :: extension
This is really good in cases where you want to save user data. Usually, you would do that with Cloud Data. But that's slow and inefficient, especially when you have a lot of players. LocalStorage is useful in that case, because you can store everything you want to on the player's device.
I've Seen This Before.
There is another localStorage Extension, but it only allows you to use one variable. This one allows you to create as many as you would like.
Try it Out
Try it in ScratchX
Code
new (function() { var ext = this; var descriptor = { blocks: [ ['r', '%s', 'readLocalStorage', 'highscore'], [' ', 'set %s to %s', 'setLocalStorage', 'highscore', '12'], ], url : 'https://jgames101.github.io/scratch-extensions/localstorage.html' }; ext._shutdown = function() { }; ext._getStatus = function() { if (window.localStorage) { return {status:2, msg:'LocalStorage supported by your browser!'}; } else { return {status:0, msg:'LocalStorage is not supported by your browser. Try recent versions of Chrome or Firefox.'}; }; }; ext.readLocalStorage = function(name) { return localStorage.getItem(name); }; ext.setLocalStorage = function(name, value) { return localStorage.setItem(name, value); }; ScratchExtensions.register('LocalStorage Variables', descriptor, ext); })();
If you like this extension, check out my previous one, Desktop Notifications.
Last edited by JGames101 (Nov. 13, 2017 07:08:49)
- savaka
- Scratcher
1000+ posts
LocalStorage Variables Extension
Try it in Scratch 3do you mean ScratchX?
- JGames101
- Scratcher
100+ posts
LocalStorage Variables Extension
Woops yes thank you xDTry it in Scratch 3do you mean ScratchX?
- JGames101
- Scratcher
100+ posts
LocalStorage Variables Extension
Yes, it does Does it support letters?
- Blue_Science
- Scratcher
100+ posts
LocalStorage Variables Extension
Does this works with cookies or is it anything else ?
- Discussion Forums
- » Developing Scratch Extensions
- » LocalStorage Variables Extension