Database structure
As mentioned in the PhoenixSpeak overview, the structure of a Dream’s PhoenixSpeak database can be best explained as being divided into Tables, Rows and Entries. The table is the biggest part of the database; it's the overlying structure that all the data is in. PS automatically comes with two tables by default, the Dream table, and character table. Later on in this reference page, how to make more custom tables is presented.
So, inside the table, you can add rows in it, which are the next way to subdivide. Finally, there's the individual entries that are in each row.
For instance, this entire box is a representation of a table:
Table of Mysterious Rows and Entries
Row 1
|
Entry 1. Each row can have as many entries as it needs.
|
Entry 2, plain and simple.
|
See, row 1 has a third entry.
|
Row 2
|
These are row 2's entries.
|
Row 2 could have 20 entries if it wanted, but then we would run out of room on the webpage.
|
|
Row 3
|
Row 3 has only this entry.
|
|
|
Entries and rows
The smallest yet most common unit within a PhoenixSpeak Database is the entry.
Entries can contain either text or numbers, and even be used to convert data freely between both types. This makes them the PhoenixSpeak equivalent of variables as well as strings. Here is an example:
We can set PS info to be a string of text, but use numbers as the data:
(5:605) memorize that the PhoenixSpeak info {Text to number} about this Dream will now be {1234}.
We can then grab the same PS info as a variable, so if we emit the value as a result, we’d end up with the number:
(5:612) remember the PhoenixSpeak info {Text to number} about this Dream, and put it in variable %result.
(5:200) emit message {The result is %result} to the triggering player.
For this, the result would be 1234.
Rows are subsections of tables that allow for a greater degree of control as well as organization of the data within it.
Tables
Think of tables as a sort of dictionary that you can read and write data to that will not be erased when the Dream is reuploaded (unlike entry codes, variables, and strings, which are erased upon reupload). The name of the dictionary itself would be the name of the table.
By default, PhoenixSpeak caters for two predefined tables (or dictionaries in our metaphorical example) and has Dragonspeak lines to handle those properly. However, you can still manually create and use custom tables to an extent, but we’ll get to that later. First let's look at the two default tables: the Dream and the Character tables.
Dream table
Think of the Dream table as a dictionary that can have multiple words defined on the pages, but only ever lists just one definition per word. The Dream table is therefore not as flexible as the character tables (we will get to that later) but it does have its own purposes. For this example, let’s treat the Dream table as an actual dictionary, and try to define the word lie using it:
(5:605) memorize that the PhoenixSpeak info {lie} about this Dream will now be {to be in a horizontal or resting position on a supporting surface.}.
We can only store one definition of the word using the Dream table, unless we add more text to the word itself. This might not seem very useful at first, but it uses slightly less data than the character table would have since it didn’t dedicate an entire page to just that single word.
As mentioned under Maintenance Commands in the PhoenixSpeak overview, there are many commands Dream Owners can use. We can take a closer look at the entry we just made in the Dream table through the use of the ps get command:
ps get dream
PS Ok: get: result: lie='to be in a horizontal or resting position on a supporting surface.'
Visually, this is what our current Dream table would look like as our dictionary:
DREAM TABLE
|
Definition (Entry 1)
|
lie
|
to be in a horizontal or resting position on a supporting surface.
|
Character Table
In our previous example, we showed that the Dream table can only store one definition per word. In other words, it can store only one entry per row. We can also continue this metaphor by thinking of the character table as a sort of dictionary that has one word per page, but the page can fit as many definitions of the word as will fit on that page (it's limited in memory).
So, let's define the word lie by giving it two definitions:
(5:604) memorize that the PhoenixSpeak info {definition 1} about the furre named {lie} will now be {to be in a horizontal or resting position on a supporting surface.}.
(5:604) memorize that the PhoenixSpeak info {definition 2} about the furre named {lie} will now be {an intentionally false statement.}.
Visually, this is what our current character table would look like as a dictionary:
CHARACTER TABLE
|
Definition 1 (Entry 1)
|
Definition 2 (Entry 2)
|
lie
|
to be in a horizontal or resting position on a supporting surface.
|
an intentionally false statement.
|
We can take a closer look at this through the use of the ps get command once again for the character table, specifically at the row called lie:
ps get character[ ‘lie’ ]: 1
PS Ok: get: result: 1='to be in a horizontal or resting position on a supporting surface.'
ps get character[ ‘lie’ ]: 2
PS Ok: get: result: 2='an intentionally false statement.'
Or you can grab all of the definitions at once by looking up the row name:
ps get character[‘lie’]
PS Ok: get: result: 1='to be in a horizontal or resting position on a supporting surface.', 2='an intentionally false statement.'
So, the character table is mostly used for storing individual player stats (but there are other uses, mentioned later), where an entire page is dedicated to a specific person. We’ll call each person’s page a row. Every player can get their own row in the character table, and the row is named after the player's own name.
It is also worth noting that the character table is special because the amount of rows that may be contained within it is limited.
All Dreams have a certain amount of data available to use for free, but your Dream can have more space if you have a Group Package. So, the amount of data you can have is dependant on the type of Group Package your Dream has. You can read more about the limits on the Group Packages page!
Share this:
-
-
-