The Database
script is a spot to keep all of your game settings for the various systems to read. Each entry in the Database is a script representing that data like Collectable Data
or Screen Data
. You can have multiple Databases to spread data around and organize it. You can also remix an existing Data script or make your own to build and store your own game data.
The types of data we included with Doodle Safari are:
Collectable Data - Used to add information about Collectables for use in other systems.
Collectable Drop Data - Used to define lists of Collectables that drop out of things like Collectable Containers.
Cosmetic Data - Used for purchasing cosmetics.
Purchasable Data - Used for purchasing arbitrary things like access to an area or any other thing that isn’t a Collectable or Cosmetic.
Screen Data - Defines settings for screens. This data is used by the “Screen Manager”.
Trade Data - Used to swap one Collectable for another.
Some common fields on data that can help other scripts display it or get access to it are:
Display Name - Several scripts will look for this to write a more readable name into UI.
Description - This can be useful for writing a more in depth description of data into some UI.
Tags - These can be used by scripts to grab a specific subset of data that share tags.
The Database can be queried by other scripts using:
this.game.sendEventToTag(“database”, “getData”, “myDataId”, (data: any) => {
// Work with data here
});
There are several other methods that can get data in various ways. These can be found in the documentation in the Database
script.