GM Database Support v3.1.1 by Alasdair Forsythe (www.gmdatabase.co.uk)
These are the most basic database scripts that you will most likely be using.
Remember that if you're not using encryption then you'll need to add a blank script called 'encryption' anyway.
To import these scripts into your game select 'Import Scripts' from the Game Maker 'File' menu and then locate the 'Database: Basic' script file. You should delete any scripts that you're not using so as the game will load faster.
To call the scripts use the format
as shown below. You can call a script at any time during the game.
Eg. to set the variable jeff to the value of the 4th
column, 3rd row, in the 1st table of database
file data.txt use:
jeff=lookup_direct('data.txt',1,4,3)
On the overviews of the scripts below the format shows you what to put in each argument.
Argument types is the type of argument required: string,
real or adv.
Adv means it uses the advanced search which just means that:
If any of the scripts fail they return -1.
lookup_direct
insert_direct
ins_table_direct
database_info
lookup_direct:
format: lookup_direct(file_name,z,x,y,change_to)
argument types: lookup_direct(string,adv,adv,adv,string)
This script is the most important one of all, it enables you to
check a database directly (from the file) and return/change the
value of any cell in that database.
0 can be entered for x/y to make
it check for the name of that row/col (see last section). If 0
is put for both x and y then it'll return the name of that table.
The value returned is always a string.
insert_direct:
format: insert_direct(file_name,z,pos,col/row,ins/del)
argument types: insert_direct(string,adv,real,true/false,true/false)
This script inserts/deletes columns/rows in a certain table of
a database file.
You'll need to use the lookup_direct script to change the value of the cells in a new column/row.
ins_table_direct:
format: ins_table_direct(file_name,pos,ins/del/clr,cols,rows)
argument types: ins_table_direct(string,adv,0/1/2,real,real)
This script inserts a blank cols*rows table at position pos, you'll need to edit the cells.
database_info:
format: database_info(file_name,z,x,y)
argument types: database_info(string,real,real,real)
This script returns a certain piece of information about the database file. It always returns a real value.