Original Source
- Original title: Database Extender
- Original author: Der Botaniker
- Original date: March 20, 2013
- Source thread: https://forums.rpgmakerweb.com/threads/database-extender.10693/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS3 Scripts (RMVX Ace)
Summary
Database Extender Thanks Hiino for the translation I think that the RPG Maker database is a bit of a pain since we cannot extend it. Hence, I am obligated to stay in the quite restrictive base system, and, in order to obtain cooler (and more specific) things I have to abuse of the database's commentary/note fields (and why not complete with the Typed Entities script, which isn't adapted to this kind of things... IN MY OPINION!) So I plagiarized Avygeil who had already been plagiarized by Grim and recoded a...
Archived First Post
Thanks Hiino for the translation
I think that the RPG Maker database is a bit of a pain since we cannot extend it. Hence, I am obligated to stay in the quite restrictive base system, and, in order to obtain cooler (and more specific) things I have to abuse of the database's commentary/note fields (and why not complete with the Typed Entities script, which isn't adapted to this kind of things... IN MY OPINION!)
So I plagiarized Avygeil who had already been plagiarized by Grim and recoded a database system for RM.
Concept
This system is based on the same idea as the one Grim used in his "Expressive Database", except it's a bit better (and more cleverly) coded. So firstly we are going to create tables in a blank script on top of Main. To achieve this, simply write:
class Swords < Database::Table # Here we will define our table's fieldsendTo add fields that characterize our table, we have to set their type and their name.
The script accepts the following types:
- :string - Represents text data
- :integer - Represents an integer number
- :float - Represents a floating point number
- :boolean - Represents either true or false (a switch)
- olymorphic - Represents any RM data type
class Swords < Database::Table integer :id string :name string :description float :cost integer :powerendclass Pokemon < Database::Table integer :id string :name string :description string :type integer :powerend
The goal is to describe every attribute of our tables. Of course, these exaples are quite naive and not finished.
How to fill our database
There are two ways of filling our database.
The first one is the most economic: after having defined our fields, we can use the "insert" command and pass it arguments. If said arguments aren't the right type the script will try to convert them, else it will set them a default value according to their type. Here is an example:
class Swords < Database::Table # Design of the table integer :id string :name string :description float :cost integer ower # Filling insert 0, "Excalibur", "A rare sword", 150.50, 120 insert 1, "Durendal", "A very rare sword", 200.20, 200 insert 2, "Dard", "Bilbon's, then Frodon's sword", 30.0, 50endclass Pokemon < Database::Table # Design of the table integer :id string :name string :description string :type integer ower # Filling insert 0, "Pikachu", "Ugly green mouse", "Electric", 10 insert 1, "Pichu", "Same as above", "Electric", 5 insert 2, "Doraemon", "thing", "Fire", 100 insert 3, "Sangoku", "Legendary Pokemon", "Rare", 1000 endAlso, it is possible to instantiate objects this way:
Pokemon.new(id: 4, name: "Mew", description: "Blue monkey", type: "Plant", power: 999)Pokemon.new(id: 5, name: "Magicalichigo", description: "Looks like an Evoli", type: "Psy", power: 1)
Access a table
We just have to writeatabase.tables[:Table_Name] or Database.Table_Name
For example: Database.Pokemon or Database.tables[okemon]
Then Database.Pokemon[0] will return the first record (Pikachu), but since the fields are stored inside an array, it is possible to use all the methods concerning arrays. However this part only addresses scripters, kind of like this whole script actually
Process the initial RPG Maker database
Since this script is modern and cool, it also allows for handling the RPG Maker database with the same primitives.
For example, to access the Actors table of the database, we will write: Database.VXACE_Actors, which returns the array of all the database's actors.
The accessible tables:
- VXACE_Actors
- VXACE_Classes
- VXACE_Skills
- VXACE_Items
- VXACE_Weapons
- VXACE_Armors
- VXACE_Enemies
- VXACE_States
- VXACE_Animations
- VXACE_Tilesets
- VXACE_CommonEvents
- VXACE_MapInfos
Associating with the Event Extender
If the Event Extender is already appended to your project, you have to place this script below it, so that its database overrides the Event Extender's.
The Design/Filling works the ame way as detailed above.
To access the database, it works as usual or as documented in the Event Extender (for example T[okemon] or T[:VXACE_Actors]).
Thanks to Hiino for his proofreading and translation!
Code
Permalink
If I update the script, it will usually be on this page: https://github.com/Funkywork/Scripts-rm/blob/master/VXAce/Extend-Database.rb
And the official Page : http://www.biloucorp.com/index.php?page=article&id_article=4
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...