GM Database Support v3.1.1 by Alasdair Forsythe (www.gmdatabase.co.uk)

Beginner

Okay. Here we are, version 3.1.1 of GM Database Support and you want to know how to use it.

As a beginner I am expecting you to not know much about code, you still use the drag-and-drop aspect of Game Maker, if you do know GML and how scripts work then check out the advanced scripts, you can do much more with them.

Although these scripts are exactly the same as the ones in the advanced section I'm only going to trouble you with the basic scripts as many of the others may well confuse you so I'm trying to keep it simple. Also make sure you have a good look at the examples after reading this (the advanced ones as well) to give you an idea of what you can achieve as a beginner and some of the possibilities of using GM Database Support at more advanced levels.

If you really struggle with using these scripts then I've created a drag-and-drop library so you can use GM Database Support without having to use any kind of code at all.

Remember that if you're not using encryption then you'll need to add a blank script called 'encryption' anyway.


When I refer to a cell I mean the string in a database file under a certain table, column and row.

When I refer to a string I mean anything inside a ' or ".
Eg.
'Hello' or "123".

When I refer to a real value I mean just a number.
Eg.
0 or 23.

When I refer to a value being returned this means that this is the answer the script gives and you can use it in an if statement or make a variable equal to it.
Eg.
variable=lookup_direct('data.txt',1,2,2) or if lookup_direct('data.txt',1,2,2)=='Hello' variable=1.

When I refer to an argument then that means one of the string or real values that are put inside the brackets when calling upon a script.
The first argument is called argument0, the second argument1, etc.


Scripts At Beginner Level

lookup_direct
insert_direct
database_info


lookup_direct

The first and main script you'll be using is lookup_direct. This script has two main functions. It can either return the value of any cell in a database file or it can change the value of any cell in a database file.

To use this script you'll need to call upon it with 4 or 5 arguments. 4 if you want the value of a cell to be returned. 5 arguments if you want to change the value of the cell, in which case the fifth argument must be a string.

This script looks as follows: lookup_direct(argument0,argument1,argument2,argument3,argument4)

You can also find out or change a column name by entering 0 as a row.
You can find out or change a row name by entering 0 as a column.
And you can find out or change a table name by entering 0 as both the column and the row.

Here is an example of getting the lookup_direct script to give the value of a cell at table 2, column 4, row 3, in database data.txt:
lookup_direct('data.txt',2,4,3)

Here is an example of getting the lookup_direct script to give the value of a cell at table 1, the column called Strength, row 2, in database data.txt:
lookup_direct('data.txt',1,'Strength',2)

Here is an example of getting the lookup_direct script to change the name of table 4 in database data.txt to Table4:
lookup_direct('data.txt',4,0,0,'Table4')

 

insert_direct

This script is used to either insert or delete a column or row to a table in a database file.

To use this script you'll need to call upon it with 5 arguments.

This script looks as follows: insert_direct(argument0,argument1,argument2,argument3,argument4)

Here is an example of getting the insert_direct script to insert a column at position 5 in table 2 of database data.txt:
insert_direct('data.txt',2,5,1,1)

Here is an example of getting the insert_direct script to delete a row at position 5 in the table called goofy of database data.txt:
insert_direct('data.txt','goofy',5,0,0)

Here is an example of getting the insert_direct script to insert a row at the last position in table 1 of database data.txt:
insert_direct('data.txt',1,0,0,1)

 

database_info

This is a very useful script enabling you to get a certain piece of information from a database file.

To use this script you'll need to call upon it with 4 arguments. The first argument is the database path or filename like usual. The 3 following arguments are all real values.

This script looks as follows: insert_direct(argument0,argument1,argument2,argument3)

Here is an example of getting the total tables in database data.txt:
database_info('data.txt',1,0,0)

Here is an example of getting the total number of columns in table 3 of database data.txt:
database_info('data.txt',3,1,0)

Here is an example of getting the total number of rows in the table called Shop of database data.txt:
database_info('data.txt','Shop',0,1)