|
1 | 1 | # Local Storage |
2 | 2 |
|
3 | | -The local storage etension allows you to automatically save plain text in a storage space provided by the browser. Forget save codes! With this extension, we can make a game that doesn't require any user interaction to save progress. |
| 3 | +The local storage extension allows you to automatically save plain text in a storage space provided by the browser. Forget save codes! With this extension, we can make a game that doesn't require any user interaction to save progress. |
4 | 4 |
|
5 | 5 | ## Namespaces |
6 | 6 |
|
7 | | -A namespace is basically like the file in the browser's storage you want to save your codes in. Every project should use a unique namespace. If two projects use the same namespace, then they will overwrite each other's storage and they'll probably both end up broken :( |
| 7 | +A namespace is basically the file in the browser's storage you want to save your codes in. Every project should use a unique namespace. If two projects use the same namespace, they will overwrite each other's storage and they'll probably both end up broken :( |
8 | 8 |
|
9 | 9 | By default, the extension generates a random namespace for you and saves this inside the project, **so you shouldn't need to worry about managing the namespace yourself**. You should still be aware of what a namespace is since changing it could break your project. |
10 | 10 |
|
11 | 11 | In older versions of the extension, it was necessary to configure the namespace by running the set namespace block at the start of your project. This block should not be needed anymore unless you are doing something very advanced. For example, if you want to access variables stored in another project, you can find that project's namespace and then set your namespace to the same thing. This would let you access the values that project stored. |
12 | 12 |
|
13 | 13 | ## Basic usage |
14 | 14 |
|
15 | | -Think of local storage as providing a special type of variable that automatically persists between sessions. Rather than using the "Make a Variable" button to make a new variable, you just type its name into an input. Unlike normal cloud variables, local storage is not restricted to just numbers. |
| 15 | +Think of local storage as providing a special type of variable that persists between sessions. Rather than using the "Make a Variable" button to make a new variable, you just type its name into an input. Unlike normal cloud variables, local storage is not restricted to just numbers. |
16 | 16 |
|
17 | 17 | To put a value into storage, use this block: |
18 | 18 |
|
@@ -88,7 +88,7 @@ The "correct" behavior to do in this type of scenario is heavily context-depende |
88 | 88 |
|
89 | 89 | ## Read and write all at once |
90 | 90 |
|
91 | | -For projects are confident they will only be open in one window at once or that rely on manual saving where indiscriminently overwriting the old save is the expected outcome, the simplest approach is to read all values from storage into regular variables at the start, then your game does all its logic using just the regular variables. To save, your game puts these regular variabels back in storage. Here's what that looks like: |
| 91 | +For projects are confident they will only be open in one window at once, or ones that rely on manual saving where indiscriminently overwriting the old save is the expected outcome, the simplest approach is to read all values from storage into regular variables at the start, then your game does all its logic using just the regular variables. To save, your game puts these regular variabels back in storage. Here's what that looks like: |
92 | 92 |
|
93 | 93 | ```scratch |
94 | 94 | when i receive [start v] |
@@ -129,7 +129,7 @@ Because changes to storage are always being re-read instead of being stored in a |
129 | 129 | Pros: |
130 | 130 |
|
131 | 131 | * Still pretty simple. |
132 | | - * Avoid unnecessary variable. |
| 132 | + * Avoids unnecessary variables. |
133 | 133 | * Changes to storage are instantly available to all windows at the same time. |
134 | 134 |
|
135 | 135 | Cons: |
|
0 commit comments