Skip to content

Commit 3d08ca6

Browse files
sovdeethgitbook-bot
authored andcommitted
GitBook: [#49] No subject
1 parent 3fc769b commit 3d08ca6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

core-concepts/variables/memory-variables-metadata-and-alternatives.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,21 @@ default:
3030
# I recommend to use a single character to denote unsaved variables (similar to local variables' '_'), e.g. '-', in which case the last database's pattern should be '(?!-).*'.
3131
```
3232

33-
The last four lines of comments describe how to enable memory variables. In simple terms, you just replace the `pattern:` line with a new regex pattern, one that excludes variables that start with `-`. As you can see in the comments, this pattern is `(?!-).*`. 
33+
The last four lines of comments describe how to enable memory variables. In simple terms, you just replace the `pattern:` line with a new regex pattern, one that excludes variables that start with `-`. As you can see in the comments, this pattern is `(?!-).*`.
3434

35-
However, know that you can set this pattern to whatever you want, which also means your memory variables can follow whatever format you want, as long as you set the pattern up properly. I advise sticking with convention and using `-`.
35+
Your edited config should look like this:
36+
37+
```yaml
38+
type: CSV
39+
40+
pattern: (?!-}.*
41+
42+
file: ./plugins/Skript/variables.csv
43+
44+
backup interval: 2 hours
45+
```
46+
47+
However, know that you can set this pattern to whatever you want, which also means your memory variables can follow whatever format you want as long as you set the pattern up properly. I advise sticking with convention and using `-`.
3648

3749
## Metadata
3850

@@ -73,6 +85,6 @@ There are many other ways to deal with information and data in Skript. Addons al
7385
That said, here are some general rules:
7486

7587
* Try to store the least amount of data possible for the long term. No matter your storage solution, it'll always be faster and easier if you store less information.
76-
* In this vein, try to make use of temporary structures like local variables, metadata, or memory variables. 
88+
* In this vein, try to make use of temporary structures like local variables, metadata, or memory variables.
7789
* When you're using a relatively slow method of storing data (databases, reading/writing files, etc), try to load all the relevant information **only when you need it**. When a player joins, for example, try to copy all their information from your long-term solution into a temporary, fast format like memory variables. Then, when they leave, write the updated information back to the slower, long-term storage.
7890
* Prioritize usability and readability over performance. If a high-performance solution makes your code a nightmare to read and maintain, consider not making that sacrifice. Losing a few milliseconds per tick is not worth it if it saves you hours of extra work in the future when you need to modify your code.

0 commit comments

Comments
 (0)