Using strings as lists for data storage

Strings can actually be used for data storage in a similar way as arrays, but without using any of the array lines! But, one big disadvantage to this is that strings difficult to use for extracting and manipulating data (but it's still possible with some work!). The next example will show a way to use strings as a simple database, by baking words into a string separated by spaces.

Tutorial 3: Automatic share system

Let's start off with a very basic type of string database: a list of players to share Dream control to when they arrive! Before string DS, this would be done by adding a trigger for every player you want to share control with. This isn’t necessarily taxing on DS, but it could really add up if you have a lot of staff! The following string implementation will not only save DS lines, but also give you an idea of what strings are capable of.

So in our imaginary Dream, we have a list of names of players who will get share automatically when entering the Dream. Here's how that would look written out:

(0:0) When everything is starting up,

(5:250) set message ~ShareList to { Example|Furre1 Example|Furre2 Example|Furre3 }.

(0:9) When someone arrives in the Dream,

(1:75) and message ~ShareList contains { [FURRE] } somewhere within it,

(5:102) share Dream control with the triggering furre.

We are adding the names of players (with the | (pipe) character replacing any spaces), separated by spaces. Then, when a player whose name is included in the list arrives, they get share.

Notice, however, that when we use the (1:75) line, it's looking for ‘ [FURRE] ‘ rather than just ‘[FURRE]’. Why? Well, imagine a scenario where we put ‘Joey’ on our share list, and a player named ‘Joe’ arrives in our Dream. In this rather troublesome, yet rare instance, ‘Joe’ will receive share because the string contains ‘Joe’ (as ‘Joe’ is part of ‘Joey’). We get around this by using spaces as separators, since spaces are not an allowed character within a character’s name.

As we're talking about spaces in strings, it's also probably worth mentioning that when two or more elements of the data in a string are separated in spaces, they are separated into words (something mentioned in various string DS lines). For example, ‘Example|Furre1’ is the very first word in the ~ShareList string, while ‘Example|Furre2’ is the second, and so on.

Account E-Mail

Password