Custom Database

Custom Database

Author: Tsukihime

Overview

This script provides a set of methods that allow you to add new objects to the database and update existing objects in database.

It abstracts all of the details for you and provides a set of simple-to-use methods for interacting with the database.

The script uses a custom database to record any changes to the database in your current game, and is stored with the savefile so that any changes in one game does not affect any other game.

The custom database only supports adding and updating at the moment.

Download

Get it at Hime Works

Usage

Creating objects

A set of "add" methods have been provided for you in the script.

Suppose you wanted to make a new weapon. It would look something like

# create your weaponw = RPG::Weapon.neww.wtype_id = 1 w.params = [999] * 8 # make it overpowered# now add it to the databaseid = CustomData.add_weapon(w)# you can do something with the IDThe general process is to create the RPG object, add it to the database, and then use that ID somewhere.

Updating objects

To update an object, you would call the appropriate `update` method provided by the script.

For example, if you wanted to update a skill's MP cost, you might do something like

Code:
# Updating skill 51s = $data_skills[51]# change its mp costs.mp_cost = 20# now update the databaseCustomData.update_skill(s)
You don't have to credit me for this 🙂
I copied it over from the other forums didn't really check the post thoroughly lol
Several updates have been made recently.

A set of API methods have been provided so that you don't need to know anything about how the script works. And it would be better to use them since I can change the internal workings at any time.

You can now add new objects to the database, as well as update existing objects in the database using the standnardized methods.

The methods of interest can be found in the script under the CustomData module

add_weapon(obj)update_weapon(obj)add_actor(obj)update_actor(obj)add_class(obj)update_class(obj)...Notice that all methods take an object, which is an appropriate RPG object. The only thing you need to interact with the custom database is a reference to the object you wish to add or update; this is because every object has an ID, and this ID is the one you use, the one every script uses, and the ones the custom database also uses.

All custom data is stored with the save file as usual, and is merged when you load the save file.

Custom data replaces any of the original game data.

If you have custom data files, you can easily extend this script as well to account for those.
hmm I'm lost, where do I put the code to update the object? i.e. where do I put this
Code:
w = $data_weapons[4]
w.params[2] += 50
CustomData.update_weapon(w)

Edit:
I made a new script, made a "module CustomDatabase" and I'm putting the code in a "self.init" method in there, then calling "CustomDatabase" in SceneManager's "self.run", after it loads the database. Seems to work 😉

Original thread: https://forums.rpgmakerweb.com/threads/custom-database.2896/