Tutorial 2: Custom tables
For most ends and purposes, the default character and Dream tables are more than sufficient, but on the other hand it's good to know that it's also possible to create your own custom tables with the ps set command. This way you can make things like a database of important NPC’s in your Dream with descriptions about them, stats, inventory, as well as other bits and entries of information about them!
Using custom tables also allows you to set up information you'd want to use in your Dream manually without wasting any DS lines (since strings and arrays/variables are each limited to only 500 total per Dream, whereas PS is only limited by total memory used, rather than length/number). Plus, any information you set up in your database will stay when the Dream is reuploaded.
However, the downside to making custom tables is that there's currently no way to manipulate the data in custom tables through DS (they can be read though), so their usefulness is limited. But there are ways for DS to access already set up PS databases, as we will show.
Since the only ways to browse custom tables/rows/entries is through having your DS read the database or through the ps get command, it helps to keep a list of any custom tables as well as rows and entries that you have created. Plus, having a list to reference will help you keep your PhoenixSpeak database organized.
To illustrate one use of this, we'll use the previous example of making a database of NPC’s.
First, we need to create the custom table that will hold the information and data about the NPC’s in our Dream. We will call it NPC_DB:
ps set NPC_DB
If we use the ps get command, we'll see that it was created:
ps get NPC_DB
PS Ok: get: result:NPC_DB='<array>'
Now we can add rows and entries to this table with the ps set command. For instance, we can create a new, empty row in our NPC_DB table called AnthonyTheWizard:
ps set NPC_DB[ ‘AnthonyTheWizard’ ]:
Note: Make sure you don't forget to add the : at the end of the command!
And now when we use ps get again, we'll see our new row in there:
ps get NPC_DB
PS Ok: get: result:AnthonyTheWizard='<array>'
Finally, we can add an entry once again by using the ps set command one last time. Let's add a new entry called Description.
ps set NPC_DB[ ‘AnthonyTheWizard’ ]: Description=”Anthony is a Wizard that hails from a kingdom far away, hidden amongst the clouds in the highest of mountains to the North.”
The database shows it here when we use ps get:
ps get NPC_DB[ 'AnthonyTheWizard' ]: Description
PS Ok: get: result: Description='Anthony is a Wizard that hails from a kingdom far away, hidden amongst the clouds in the highest of mountains to the North.'
As of now, custom tables, rows, and entries can only be manipulated through the use of 3rd party programs (which are not officially supported), but their values can also be copied into both character and Dream table entries (which do allow manipulation), through a method that will be illustrated further down in the PhoenixSpeak manipulation section.