Jump to content


Photo

Gmsdb 3.1 - Game Maker Simple Database


  • Please log in to reply
88 replies to this topic

#1 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 15 March 2013 - 05:52 PM

GMSDB is a database system written entirely in GML that can be used in any kind of project requiring a simple solution to store and retrieve organized data.

With GMSDB you can easily perform basic CRUD (create,read,update,delete) operations on a database table while applying custom filters, sorting, limits, offsets, calculations and joins on the result set.

 

Features

  • Doesn't require any external extension like DLLs etc.
  • Comprehensive and flexible query system
  • Ability to sort, filter, limit, offset and join your query result
  • Load and save the whole database or specific table to file
  • Import and export table data from and to CSV file to be use with excel
  • Well commented code and extensive documentation
  • Get started with the included examples showing how to build a simple highscore and inventory system
  • Includes some useful generic CSV parsing scripts

 

Links

 

Get it in the marketplace

Demo (exe)

 

Documentation 

 

Function reference, getting started and installation

Example snippet 

Spoiler

 

Version 3.1
Uploaded March 24 2016

 

read this before upgrading an existing project from 3.0 to 3.1

 

  • New: added db_table_column_add and db_table_column_remove
  • New: multi column sort. You can now sort query results by two or more columns
  • New: Ability to return records represented as a ds_map, with column names as keys. The following functions have been added to this purpose:  db_record_fetch, db_record_fetch_all, db_record_save, db_record_build
  • Changed: db_query_select can now return a ds_list of record ids if only the "id" column is provided as argument
  • Changed: db_record_rnd now requires a second argument telling how many random record ids you want to return. If more than one, a ds_list is returned
  • Changed: db_record_update now accepts multiple columns and values to be updated at once
  • Changed: db_cl_sort arguments have been changed to accept multiple column. Arguments are now structured as follows: db_cl_sort(query,"column_name:asc", ["column_name:desc"],...)
  • Changed: db_table_create columns need to be specified as "column:type" instead of "column|type"
  • Improved general performance of queries
  • Improved the included examples

 

 

Version 2 (discontinued)

 

Spoiler

Edited by Catan, 25 March 2016 - 12:49 PM.

  • 8

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#2 tizzio

tizzio

    GMC Member

  • GMC Member
  • 276 posts
  • Version:GM:Studio

Posted 20 March 2013 - 08:55 AM

Great extension, simple and usable on any platform, thumbs up!


  • 0

1411824224_medium.jpg?1411824224 1411379323_medium.jpg?1411379323  1438287288_medium.jpg?1438287288


#3 gearmex

gearmex

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM:Studio

Posted 21 March 2013 - 03:39 AM

Exactly what i need!


  • 1

#4 Mack151

Mack151

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM:Studio

Posted 10 April 2013 - 06:24 PM

This looks like it'll be immensely helpful! One question, though -- if I set an attribute to store real values, will it properly parse constants and resource names when specifying the values as a single string, like so?

 

db_table_create("db_oversprites",
                "idle_r|real,idle_u|real,idle_l|real,idle_d|real,"
               +"walk_r|real,walk_u|real,walk_l|real,walk_d|real,"
               +"run_r|real,run_u|real,run_l|real,run_d|real,"
               +"talk_r|real,talk_u|real,talk_l|real,talk_d|real");

//0 -- Template Character
db_record_insert("db_oversprites",
                 "spr_basechar_r_idle,spr_basechar_u_idle,spr_basechar_l_idle,spr_basechar_d_idle,"
                +"spr_basechar_r_walk,spr_basechar_u_walk,spr_basechar_l_walk,spr_basechar_d_walk,"
                +"spr_basechar_r_run,spr_basechar_u_run,spr_basechar_l_run,spr_basechar_d_run,"
                +"spr_basechar_r_talk,spr_basechar_u_talk,spr_basechar_l_talk,spr_basechar_d_talk"); 

 

Or do I need to specify them as individual arguments? Doing so would limit me to 15 attributes since GameMaker would complain about having too many arguments in the script, and that means I'd have to split it into two tables.


Edited by Mack151, 10 April 2013 - 07:01 PM.

  • 0

You opened the mailbox.
Nothing was in it.
Nothing after nothing came bursting out of the mailbox.


#5 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 10 April 2013 - 07:22 PM

It will not parse resource names, but since resource names are actually numbers, you can always do something like this to avoid being limited to 15 arguments:

 

db_record_insert("db_oversprites",
                 string(spr_basechar_r_idle)+","+string(spr_basechar_u_idle)+","
                +string(spr_basechar_l_idle)+","+string(spr_basechar_r_walk)+","
                +string(spr_basechar_u_walk)+","+string(spr_basechar_l_walk)+","
                +...

It is also possible to generate the string from a ds_list of values (see csv_ functions in the docs) by creating a ds_list of sprites and passing csv_compose_line(list_of_sprites,",") as the second argument of db_record_insert.


Edited by Catan, 10 April 2013 - 07:34 PM.

  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#6 Mack151

Mack151

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM:Studio

Posted 10 April 2013 - 07:38 PM

It will not parse resource names, but since resource names are actually numbers, you can always do something like this to avoid being limited to 15 arguments:

 

db_record_insert("db_oversprites",
                 string(spr_basechar_r_idle)+","+string(spr_basechar_u_idle)+","
                +string(spr_basechar_l_idle)+","+string(spr_basechar_r_walk)+","
                +string(spr_basechar_u_walk)+","+string(spr_basechar_l_walk)+","
                +...

It is also possible to generate the string from a ds_list of values (see csv_ functions in the docs) by creating a ds_list of sprites and passing csv_compose_line(list_of_sprites,",") as the second argument of db_record_insert.


Oh, man, that makes way too much sense! Thanks!


  • 0

You opened the mailbox.
Nothing was in it.
Nothing after nothing came bursting out of the mailbox.


#7 manji

manji

    GMC Member

  • New Member
  • 8 posts
  • Version:GM:Studio

Posted 24 April 2013 - 02:36 PM

could you pls provide an example how a working insert_to_csv script should look like?

 

I am having troubles with creating one


Edited by manji, 24 April 2013 - 08:47 PM.

  • 0

#8 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 25 April 2013 - 06:48 AM

Hi manji!

 

Have you solved the problem you described earlier?

 

About db_record_insert_csv(table_name,path_to_file,separator): table_name is like in any other db_call, a string with the name of the table you want your csv values to be saved in. Path to file should be the absolute path of the csv you want to import, and separator is the delimiter character used to separate values in the CSV. Usually in a CSV file the separator is rhe ',' character, but in some localized versions of excel (mostly europe) ';' is used instead (open your CSV with a text editor and check what character you have).

 

This means that probably you need to do the call like this: db_record_insert_csv("awesome_table",working_directory+"\awesome_table.csv",";").

 

There are a couple of important things to remember: first of all, on record insertion (even from CSV) the record id is generated automatically, so you CAN'T pass the id from the CSV. This also means that if you want to import a CSV file generated from db_table_to_csv, you first have to delete the id column.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#9 manji

manji

    GMC Member

  • New Member
  • 8 posts
  • Version:GM:Studio

Posted 26 April 2013 - 12:28 PM

Hi, with the record get thing, yes, I did! I am an idiot and didn't convert target"variable" to strings....

 

Oh thx :D there were 2 thought errors xD

 

I somehow thought, that with that funktion you "make" a csv ... I missunderstood!

 

Also I thought that 1 is (for example) the separator, like 1 tab, but now its crystal clear how it works, thank you for the explanation!

 

 

Btw. the DB system is nice, and totally something I want to use in my project! 

 

I still have one further question!

 

The db_free() just clears the memory? so dbs would need to be read by files in again, or does it close the whole DB system and i need to db_init() again?! 

 

I haven't tryed yet, so I just ask xD


Edited by manji, 26 April 2013 - 12:33 PM.

  • 0

#10 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 26 April 2013 - 12:44 PM

db_record_insert_csv loads CSV data into the database, while db_table_to_csv saves the data to CSV. Remember that CSV are useful when you need to edit the data externally during the development, but if you just want to save (or load) the database you have to use db_table_write and db_table_read.

 

db_free clears the memory AND closes the system, this means you have to call db_init again if you want to use the database again after that.


Edited by Catan, 26 April 2013 - 12:45 PM.

  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#11 manji

manji

    GMC Member

  • New Member
  • 8 posts
  • Version:GM:Studio

Posted 26 April 2013 - 01:34 PM

thank you very much!


  • 0

#12 Archangel7x

Archangel7x

    GMC Member

  • GMC Member
  • 236 posts
  • Version:Unknown

Posted 25 May 2013 - 03:19 AM

I cannot seem to figure this out

if argument0.iStats[z,0] = string(db_record_get("properties", tn, "property")){
   argument0.iStats[z,1] += random_range(db_record_get("properties", tn, "lr"),db_record_get("properties", tn, "hr"));
   }

this does'nt work any reason why?

it doesnt seem to compare these correctly and always skips this statement


  • 0

#13 manji

manji

    GMC Member

  • New Member
  • 8 posts
  • Version:GM:Studio

Posted 25 May 2013 - 11:21 AM

I cannot seem to figure this out

if argument0.iStats[z,0] = string(db_record_get("properties", tn, "property")){
   argument0.iStats[z,1] += random_range(db_record_get("properties", tn, "lr"),db_record_get("properties", tn, "hr"));
   }

this does'nt work any reason why?

it doesnt seem to compare these correctly and always skips this statement

 

try 

 

If X == Y for comparation 

 

= is for setting a value

== is for comparing


Edited by manji, 25 May 2013 - 11:21 AM.

  • 0

#14 Archangel7x

Archangel7x

    GMC Member

  • GMC Member
  • 236 posts
  • Version:Unknown

Posted 26 May 2013 - 12:02 AM

Edit: Fixed my problem, it was a single digit number error on my part lol...


Edited by Archangel7x, 26 May 2013 - 12:41 AM.

  • 0

#15 milfMan

milfMan

    GMC Member

  • GMC Member
  • 21 posts
  • Version:GM8.1

Posted 29 May 2013 - 05:21 AM

This looks like a winner! Great job.


  • 0

Hope or Despair... which side are you?

 

I write music (and remixes) for games. I have a few on my soundcloud: http://soundcloud.com/lcomposinger

And I have Twitter, for music and other random thoughts that may brighten your day: http://twitter.com/LComposinger

 

That's it though...

 

 

Rawr


#16 cejay2001

cejay2001

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM:Studio

Posted 24 June 2013 - 06:59 AM

I think I converted an older version of GMSDB for use with GMS.. before I saw this obviously.

 

Does this version still use ds_grids whereby table column defs, index and data is saved to file using ds_grid_write and ds_map_write?

 

If so has anyone else experienced problems writing out a table of data in GMS in the latest versions?  ds_map/grid_write was working flawlessly but I have lost confidence in it since recent versions seem to crash the runner in an inconsistent fashion.  I'm almost thinking of changing the file storage mechanism of these tables to use JSON or something..

 

Anyone else experienced problems with ds_grid_write or ds_map_write recently?

 

Cheers,

 

Chris


  • 0

#17 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 24 June 2013 - 01:48 PM

Yes the latest version still uses ds_*_write and ds_*_read to save/load tables, but it is also possible to export and import data using the CSV format (but requires a bit more work, this system is meant to be used for debug and and preparing the database in excel, not to save / load data).

 

I haven't used studio a lot recently and I'm not aware of any problems with read/write of data structures, but the scripts of this gex are all available and you are free to use or modify them as you like, therefore you can always edit the db_table_read and db_table_write functions in order to avoid using the functions mentioned above, using your own format.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#18 cejay2001

cejay2001

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM:Studio

Posted 25 June 2013 - 01:41 AM

Thanks for that info.  It appears the version of GMS I was using did in fact have a bug in the ds_map_write where it would crash badly.. and inconsistently.  That was version 1.1.1018

 

I'm now using 1.1.1044 and it is working flawlessly again.  Talk about frustrating having to debug GMS issues. 


  • 0

#19 ewagstaff

ewagstaff

    GMC Member

  • GMC Member
  • 87 posts
  • Version:GM:Studio

Posted 28 June 2013 - 10:52 PM

Speaking of GMS issues, I wanted to let everyone know there seems to be an issue with the latest Beta channel release. db_table_clear causes a fatal error because of the empty grid:

Error: Can not resize a grid with a dimension of 0

Same issue when using db_table_size to check a table with 0 items in it. I reverted to a Stable version (1.1.964) and it's working fine again. Thought I'd save others from banging their heads against the wall.


  • 0

#20 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 24 July 2013 - 07:26 AM

Speaking of GMS issues, I wanted to let everyone know there seems to be an issue with the latest Beta channel release. db_table_clear causes a fatal error because of the empty grid:

Error: Can not resize a grid with a dimension of 0

Same issue when using db_table_size to check a table with 0 items in it. I reverted to a Stable version (1.1.964) and it's working fine again. Thought I'd save others from banging their heads against the wall.

 

As ewagstaff  pointed out, turns out this is the intended behaviour of version 1.2 of studio. I understand why this change has been made, but sadly it affects how the database works when deleting all the entries.

I'll fix the problem soon and post an updated version, it's probably just a matter of deleting the table (keeping the index) when the size is 0 and recreating it when inserting the first item.


Edited by Catan, 24 July 2013 - 07:28 AM.

  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#21 iSola

iSola

    GMC Member

  • New Member
  • 2 posts
  • Version:GM:Studio

Posted 26 August 2013 - 11:14 PM

In Object table_obj, in Event KeyPress event number 73 at line 8 : function "db_record_insert" expects 2 arguments, 4 provided

error occured in GMS 1.2


  • 0

#22 Einherjar

Einherjar

    GMC Member

  • GMC Member
  • 9 posts
  • Version:GM:Studio

Posted 31 August 2013 - 02:11 PM

Could someone provide a simple working GM file so that I can see what exactly is needed?
 
I'm getting a basic error, but no idea how to fix it at all.

 

"In object PlayerGrid, event Room Start, action 1 at line 1: Unknown function or script: db_init"
 


  • 0

My Fantasy Sports Project - Help needed!


#23 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 31 August 2013 - 09:57 PM

The file provided with the extension should work, but of course the extension need to be installed first and imported into the project. Einherjar in your case i think you are trying to run the example file without the gex installed...


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#24 Einherjar

Einherjar

    GMC Member

  • GMC Member
  • 9 posts
  • Version:GM:Studio

Posted 02 September 2013 - 08:08 PM

I'm now having a similar issue to iSola - Screenshot provided (I installed the GEX file which has helped me past my original issue)

 

fa8v84.jpg


  • 0

My Fantasy Sports Project - Help needed!


#25 cybernetsurfer7

cybernetsurfer7

    GMC Member

  • New Member
  • 3 posts
  • Version:GM:Studio

Posted 04 September 2013 - 10:18 PM

Catan.  I have an idea that I'm playing around with and I'm hoping that your extension can help me figure it out.  I'm trying to create a text-based game where I have specific room information placed in a table.  The easiest way for me to do this is to have a table generated in Excel and populated with content that way.  I then would like to be able to bring content from that file, saved as a csv, and draw it as text on the screen.  That way, as players navigate throughout the game, the text dynamically changes via the text on the table.  However, I'm relatively new to GML and I'm still trying to figure out some things.  This is what I have so far:

 

db_init()
csv_parse_line("rooms", ",")
draw_text(100, 100, db_???)

 

I figured I needed to start up the database, then parse the csv (which is titled "rooms") and then to draw it.  I need to return a string for the drawing process but I'm not sure which function gives me access to the data from the csv.  Do I need to first put that into a table?


  • 0

#26 cybernetsurfer7

cybernetsurfer7

    GMC Member

  • New Member
  • 3 posts
  • Version:GM:Studio

Posted 04 September 2013 - 10:21 PM

Well, now I can stick my foot in my mouth for not reading through the documentation very well.  Looks like db_record_insert_csv would probably do the trick.


  • 0

#27 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 05 September 2013 - 03:59 PM

I just uploaded version 1.2.1, this version adds changes to studio only and should fix the errors regarding the arguments count in GMS 1.2, as well as the problem with ds_grids with size 0 when deleting all records from a table.

 

Moreover, db_record_find_ids and ds_record_find_value now use the new ds_grid_sort function to sort results, the speed when sorting large data sets is now drastically better.

 

As always, if you find any problem please let me know :)


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#28 mrsmes

mrsmes

    GMC Member

  • GMC Member
  • 1506 posts
  • Version:GM:Studio

Posted 14 September 2013 - 08:19 AM

All I really need is a login system and points system and in-game purchased points system...


  • 0

Assuming I helped you out in a questions and answers topic won't you return the favour by helping me with one my coding problems, or recommend some one who can chat to me over pms about helping and how to overcome my obstacles, after all lets just say I did help you or them or many people with similar problems, in that topic.

Here i have a topic for those of you struggling with type writer text and mugshots in your games especially if it is a rpg see the link below for more info

http://gmc.yoyogames...howtopic=619103

almost no code needed, only uses two events.

click here for the l8est version of feed the alien pizza, it has some major polished up features.


#29 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 14 September 2013 - 01:24 PM

All I really need is a login system and points system and in-game purchased points system...


Well you can do that with this extension but it's probably too much for what you need. I think for something like this you should probably program something simpler by yourself using data structures

Edited by Catan, 14 September 2013 - 01:27 PM.

  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#30 mrsmes

mrsmes

    GMC Member

  • GMC Member
  • 1506 posts
  • Version:GM:Studio

Posted 21 September 2013 - 06:40 AM

ah but for a web browser gaming site where i need to get the two games to communicate to share data, now that's a bit harder than data structures.


  • 0

Assuming I helped you out in a questions and answers topic won't you return the favour by helping me with one my coding problems, or recommend some one who can chat to me over pms about helping and how to overcome my obstacles, after all lets just say I did help you or them or many people with similar problems, in that topic.

Here i have a topic for those of you struggling with type writer text and mugshots in your games especially if it is a rpg see the link below for more info

http://gmc.yoyogames...howtopic=619103

almost no code needed, only uses two events.

click here for the l8est version of feed the alien pizza, it has some major polished up features.


#31 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 21 September 2013 - 05:19 PM

ah but for a web browser gaming site where i need to get the two games to communicate to share data, now that's a bit harder than data structures.

 

Well of course it is, in this case this extension is not what you are looking for. You probably need a server with something like mysql to manage that


Edited by Catan, 21 September 2013 - 05:19 PM.

  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#32 80xes

80xes

    GMC Member

  • New Member
  • 9 posts
  • Version:GM:Studio

Posted 25 September 2013 - 02:26 PM

Hi Catan, i'm using your extension, but when i try to export with "yoyo compiler" (windows target) i get this error:

Error : gml_Script_db_record_update:27:30: error: array subscript is not an integer
YYRValue __arg12707__((*_args[(/* local */local_i.val + 3)]));
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error : gml_Script_db_record_update:30:30: error: array subscript is not an integer
YYRValue __arg12710__((*_args[(/* local */local_i.val + 3)]));
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The script (one of two):

 

datos = string(argument1) + "," + string(argument2) + "," + string(argument3) + "," + string(argument4)
db_record_update("perfiles",id_perfil,"nombre,color,carita,sombrero",datos);

Without YYC i didn't get this error

TY!

 


  • 0

- Sorry for my bad english (or google translate) :D

80 Boxes on greenlight


#33 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 25 September 2013 - 03:52 PM

I'm sorry but I probably can't help you much with that, looks like a problem exclusive to compilation with YYC, and unfortunately I don't have it (too expensive) so I can't even try to see what's wrong...

Anyone else faced problems like this with YYC?


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#34 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 30 September 2013 - 06:37 AM

About the problem with the YYC, why don't you try with the script version of the extension? The link it's in the open post, and it's exactly the same thing as the gex. Maybe it's the gex itself generating the compilation problem.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#35 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 02 October 2013 - 08:21 PM

I'm working on version 1.3, here are the new features that I'll add:

 

- Ability to specify more than one column in the condition (this allows for more complex conditions and comparison between columns)

- Rewrite and modularization of the query functions (hopefully leading to slightly better performance)

- New functions to perform calculations on the results like count, sum, min, max, average (list of calculations not definitive)

 

There's still some work to do so i'm not planning to release this very soon, I just wanted to let you know I'm still working on this.

 

Any suggestion on new features or improvements are welcome very welcome right now.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#36 Zxqueb

Zxqueb

    GMC Member

  • New Member
  • 10 posts
  • Version:GM:Studio

Posted 09 February 2014 - 09:37 PM

Hi,

 

I'm trying to figure out how to use the GMSDB to make a card game in gamemaker.  Basically, I have a spreadsheet with the different values of 60 cards. That database (Cards) gets loaded up at the beginning of the game from an included file and seems to be working fine (at least, the values pass to a surface for drawing using the code that is included in the example project). 

 

The problem is that I have another database created  to choose random cards from the card pool and allow it to be sorted into a common pile. (the supply).

 

When I try to pull portions of the card database and store them into a variable, it is hitting me with an error code.  I'm probably doing something stupid, so I'm posting to try to get a bit of aid.  The code in question looks like this:

 

db_table_create("supply"," color1|real, size1|real, color2|real, size2|real, color3|real, size3|real, color4|real, size4|real");  //this is the same setup as Cards

supply_id_check = irandom (60);

supply_color1 = db_record_get("Cards" , supply_id_check, "color1" );

             // I have the rest of the variables set to 100 just for testing purposes and they are passing normally

 

db_record_insert("supply", supply_color1, supply_size1, supply_color2, supply_size2, supply_color3, supply_size3, supply_color4, supply_size4 );

 

 

 

The expected result is that it goes into a random id in Cards and pulls out the value of color 1 (a real from 1-6).  If I put a number in for supply_id_check it is just returning that number which doesn't seem right.  Is there another command that I should be using?

 

Any help would be greatly appreciated!!
 


  • 0

#37 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 24 February 2014 - 04:53 PM

Sorry I read your message some time ago but totally forgot to reply to you! I hope in the meantime you had been able to solve your problem. I don't understand however what happens and what you are trying to do. First of all, supply_id_check = irandom (60); can work only for testing purposes if you have at least 60 records and don't play around too much with the cards database. Also, keep in mind that GM:Studio always returns the same values for random numbers unless you call randomize() somewhere at the beginning of your game.

 

Aside from that, the code you posted looks ok, but the problem may be elsewhere... if you are still having trouble can you post some more detailed info?


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#38 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 24 February 2014 - 06:24 PM

I finally updated the extension to keep up with the new Studio versions and add some functionalities I really wanted to include from the start. This update is a huge step forward and introduces A LOT of changes, therefore it made sense to me to label this as version 2.

 

Due to the amount and entity of the changes, version 2 is NOT backwards compatible (tables however are stored as before, saved tables from previous versions can still be loaded fine). If you are already using version 1.X in your project and are fine with it, you are not forced to upgrade, as this update doesn't include bug fixes, just extra and streamlined functionalities.

 

See the open post for a summary of the major changes.


Edited by Catan, 24 February 2014 - 06:25 PM.

  • 1

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#39 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 07 June 2014 - 06:54 AM

I'm surprised to not see a lot of feedback posts here. This is a really nice extension for adding small to large amounts of data to your game. I was using the older 1.2.0 in a failed Angry-Birds/puzzle game and have just recently started adding it to my current project (a platform/privateer style game) when just now discovered that it was updated to 2.0.

 

I'm a relational database guy and am used to working with stuff like SQL scripting so the new features are a huge breath of fresh air. Will definitely replace and update my game to use the new version!

 

Thanks so much for your hard work in making such a helpful extension. Solves the whole level/game data structure problem within my game. :)

 

Oh I should also mention that your documentation's header still says that it's 1.2.0 and not 2.0. :)


Edited by jkamcmillen, 07 June 2014 - 07:41 AM.

  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#40 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 07 June 2014 - 10:03 AM

Ok I've ran into a really stupid problem.... Somehow I seem to be having issues with generating records in my tables. Specifically when it comes to strings.

 

Here is some code as an example of what I'm trying to accomplish.

db_init();

// Weapons
db_table_create("weapons", "id|real,name|string,heat_rate|real,cool_rate|real,fire_delay|real,shot_damage|real,locked|real,owned|real,cost|real");
db_query_insert("weapons", "0,BLAST RIFLE,      7,   0.6, room_speed / 4,   1, 0, 1, 240");
db_query_insert("weapons", 1, "REPEATER",         16,  0.6, room_speed / 5,   1, 0, 1, 740);
db_query_insert("weapons", 2, "SPREAD BLASTER",   20,  0.6, room_speed / 5,   1, 0, 0, 4250);
db_query_insert("weapons", 3, "FLAK GUN",         100, 2,   room_speed * 1.5, 2, 1, 0, 10330);
db_query_insert("weapons", 4, "GRENADE LAUNCHER", 20,  0.6, room_speed,       1, 1, 0, 7000);
db_query_insert("weapons", 5, "FLAME THROWER",    1,   0.6, room_speed / 20,  1, 1, 0, 5675);

var owned_weapons;
var query = db_query_select("weapons", "id,name,heat_rate,fire_delay,shot_damage");
db_cl_where(query, db_op_eq, "owned", "1");
db_cl_sort(query, "id", "ASC");
owned_weapons = db_query_exec(query);

var str = "width = " + string(ds_grid_width(owned_weapons));
show_message(str);
str = "height = " + string(ds_grid_height(owned_weapons));
show_message(str);

for(var yy = 0; yy < ds_grid_width(owned_weapons); yy += 1)
    for(var xx = 0; xx < ds_grid_width(owned_weapons); xx += 1)
    {
        show_message(ds_grid_get(owned_weapons,xx,yy));
    }

This code, instead of showing "BLAST RIFLE" would show 0 instead. And it only comes back with a message showing "height = 1" instead of 2 which is what should be going on.

 

I am using 2.0 and the latest Early Access 1.3 of Game Maker Studio. I have also installed gmsdb as a GEX import in my project AND imported the scripts from the operations.gml script as instructed in the documentation.

 

Suggestions?

 

Oh I should also note that I am running this code via a script I created called game_init if that even matters.


Edited by jkamcmillen, 07 June 2014 - 10:05 AM.

  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#41 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 07 June 2014 - 10:33 AM

Ok update on the above problem: it would seem trying to add a field called "id" is a BIG whopping no-no! As this has fixed one of my biggest problems.


  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#42 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 23 June 2014 - 11:31 AM

Sorry if I didn't reply earlier! You're absolutely right about the id column, since the system automatically creates that column for you (as it is used internally to make the lookup faster). The id columns is always there in every table, you can return it from queries and use it in clauses, just remember that you are not supposed to modify it since the system takes care of that.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#43 JZic

JZic

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 29 July 2014 - 06:30 PM

I don't get it, i create a table, insert data, make a query, execute it, and? i don't understand how to access to the info.

 

TY and sorry for my bad english.


  • 0

#44 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 29 July 2014 - 07:25 PM

The result of a select query (that is, a query used to retrieve data) is always a ds_grid. Refer to the GM:Studio manual to see how to get data from a ds_grid.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#45 JZic

JZic

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 29 July 2014 - 07:49 PM

The result of a select query (that is, a query used to retrieve data) is always a ds_grid. Refer to the GM:Studio manual to see how to get data from a ds_grid.

oh, ty :D


  • 0

#46 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 29 July 2014 - 10:37 PM

Today's update just broke the library. :/ I keep getting a "Variable index out of range argument" error inside of db_query_insert.

 

Here is the log of the crash...

 

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_player:

Pop :: Execution Error - Variable index out of range argument
 at gml_Script_db_query_insert (line 24) -     for(var i=0;i<argument_count;i+=1) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_db_query_insert (line 24)
called from - gml_Script_game_init (line 109) - db_query_insert("weapons", 0, "",      7,   0.6, (room_speed / 4),   1, 0, 1, 240,   spr_weapon_blastrifle,
called from - gml_Object_obj_player_CreateEvent_1 (line 1) - game_init();

 

My code worked before I updated today. Ideas?


  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#47 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 29 July 2014 - 10:43 PM

Here is how I'm using the functions in my code in my game_init() script:

// --- Generate Default Game Data ---
db_init();

// Weapons
db_table_create("weapons", "wpn_id|real,name|string,heat_rate|real,cool_rate|real,fire_delay|real,shot_damage|real,locked|real,owned|real,cost|real,sprite|real," +
                "description|string");

db_query_insert("weapons", 0, "",      7,   0.6, (room_speed / 4),   1, 0, 1, 240,   spr_weapon_blastrifle,
                "");

Here is the guts of the db_query_insert function in the version (2.0) I'm using:

/*
    Inserts a new record in the database table with the provided values (should be passed in column order).
    Values can either be passed as string of comma separated values, or as script arguments.
    This call doesn't generate a query.
    Arguments: table,fields
    Example (values as arguments): db_query_insert("fruits","banana","yellow",30)
    Example (values as string): db_query_insert("fruits","banana,yellow,30")
    Returns: the id of the newly created record
*/

var table,index,row,col,new_id,values,types,columns;

table = ds_map_find_value(_db_tables,argument[0]);
index = ds_map_find_value(_db_indexes,argument[0]);
types = ds_map_find_value(_db_types,argument[0]);
columns = db_table_column_names(argument[0]);

new_id = ds_map_size(index)+1;
row = ds_grid_height(table);
ds_grid_resize(table,ds_grid_width(table),ds_grid_height(table)+1);

if(ds_list_size(columns) == argument_count) {//values passed as arguments
    argument[0] = new_id;
    for(var i=0;i<argument_count;i+=1) {
        col = ds_list_find_value(columns,i);
        if(ds_map_find_value(types,col) == "real") {
            ds_grid_set(table,i,row,real(argument[i]));
        }
        else {
            ds_grid_set(table,i,row,string(argument[i]));
        }
    }
}
else { //values passed as string
    values = csv_parse_line(argument[1],",");
    ds_list_insert(values,0,new_id);
    for(var i=0;i<ds_list_size(columns);i+=1) {
        col = ds_list_find_value(columns,i);
        if(ds_map_find_value(types,col) == "real") {
            ds_grid_set(table,i,row,real(ds_list_find_value(values,i)));
        }
        else {
            ds_grid_set(table,i,row,ds_list_find_value(values,i));
        }
    }
    ds_list_destroy(values);
}

ds_map_add(index,new_id,row);
ds_list_destroy(columns);

return new_id;

  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#48 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 30 July 2014 - 01:08 AM

Ok just to make sure I didn't become crazy, I uninstalled and reinstalled the last stable version of GMS and my game worked perfectly (Simple DB Library and all) so if you made the mistake of jumping right on the current update before checking your game's code, then do what I did and it'll work just fine again.

 

In the meanwhile does this constitute a trouble ticket in the way arguments are handled now? or is it simply a change in the code of the library's functions?

 

I'm finding that the problem is in how argument_count is read. It is a read only variable, but the run-time behaves funny and erratic depending on how it's used it seems.


  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary


#49 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 30 July 2014 - 03:03 PM

Man, I've had so many problems with the scripts arguments I can't even count them. I started developing this extension when GM:S was just launched, and since then there have been a tons of changes in how script arguments are handled... I hope this is not the prelude to other changes in this sense.


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#50 jkamcmillen

jkamcmillen

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 30 July 2014 - 10:40 PM

Yeah I know that pain. :/

 

The funny thing about this problem is that it is not logical. It shouldn't be broken. I thought I would have a poke at the code and see if I could figure it out, but I'm just lost on it. You seem to be using it exactly as it was outlined in the examples in the documentation. At best I could say that internal functionality of these functions is unstable or inconsistent, but then we're probably splitting hairs at this point. They need to fix arguments and put out a quick patch or a lot of libraries are going to fail all over the place.

 

Then again we are taking about the "Beta" updates not "Stable". Would be nice to be allowed to roll-back to a specific version/update in Beta instead of having to ditch all the updates since the last Stable. Or at least the previous version. It worked fine until I goofed and updated.


Edited by jkamcmillen, 30 July 2014 - 10:51 PM.

  • 0

I make games. Check them out at www.RedAntGames.com & Follow me at @jkamcmillen

 

indiedb.png Current Project: Space Mercenary