Author Topic: Using external database in AGS game  (Read 1353 times)

Using external database in AGS game
« on: 02 May 2016, 10:39 »
Hi,

I am currently writing a sport manager with AGS (thst's odd, I know). Now, since I am thinking to include quite a big number of teams, I'd like to include all data in a separate database. In fact I am a bit worried about some tables, like the one reserved for players and the one for their names/surnames, since they would store some thousand of records. I know the basics about SQL, but I can't figure how to manage it with AGS, since I'd like to read and write data from a database. Using text files and their functions inside AGS wouldn't probably be appropriate (loop 2-3000 rows of text every time to find data of a player?), and I don't know how much is "safe" to build very long structs with 2000+ elements.

So... How could I make it? I didn't find any plugin about that, and I couldn't get any help from the previous topics about the subject.

Hi, this signature is not funny because my imagination is actually on holiday.

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
Re: Using external database in AGS game
« Reply #1 on: 03 May 2016, 09:05 »
I've written a tiny xml parser but it's genuinely shit (it cannot handle large files, and it won't help you with querying nayway).
Apart from that, if you really want to use authentic, robust SQL, then you have no choice: you need to find a way to interface AGS with a database engine (MySQL, etc.). Obviously, I suggest a local engine, installed on the computer, but noawadays I believe you can even connect to remote databases with not too much extra hassle apart from authenticaton stuff (of what a time to live in).

AGS cannot communicate with external programs natively. You could make a plugin but I don't know how good you're at programming, and it's a lot of work.

I would suggest one of these solutions :

- There is the Lua Plugin, which allows you to use Lua, and therefore the billion libraries it offers. I'm 110% sure you can do SQL with that. It's the simplest opinion imo. The only trouble will be for you to iterate on the queries results using AGS script language. It's surely possible, but annoying. Calin Leafshade, the creator of that plugin, can surely help you with manipulating the data structures.

- There is that plugin that allows you to do C# in AGS. Same principle as Lua plugin, but with C#. You'll need to google how to query SQL with C#.

- There is a plugin that interfaces with Windows' DLLs or command line (I can't remember which, and I can never find this plugin each time I look for it) but in both cases there are ways to do SQL using the command line or low-level DLLs. Just google it.
« Last Edit: 04 May 2016, 10:21 by Monsieur OUXX »
 

Re: Using external database in AGS game
« Reply #2 on: 03 May 2016, 10:32 »
Thanks for answering. I guess I'm going to use SqlLite with the lua plugin (I don't want an online database) and asking Calin for giving me some hint about how to use that properly.

Thanks again.
Hi, this signature is not funny because my imagination is actually on holiday.

Re: Using external database in AGS game
« Reply #3 on: 03 Sep 2016, 23:27 »
Hi,

I came here for the exact same reason : thinking about using AGS for a sport management game. It led me to the same question - can SQL be used along with AGS?

Did you progress on that topic?

Cheers,

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Using external database in AGS game
« Reply #4 on: 04 Sep 2016, 20:31 »
Definitely possible, because I did that to store the high scores of Floaty Rog.
I'm not making a direct connection to the SQL server though, I'm sending and receiving HTTP requests using the agsSock plugin. A small PHP api is used to handle the DB.
Not suitable for a local DB though.

Edmundito

  • Mittens Serf
    • Best Innovation Award Winner 2014, for 'Tween Module'
    • Edmundito worked on a game that was nominated for an AGS Award!
Re: Using external database in AGS game
« Reply #5 on: 10 Sep 2016, 17:12 »
Another recommendation is that you may need to not use sql db to do this but instead export all the data in JSON; this is actually what most commercial games with lots of data do. Then with the Lua plugin you may be able to load, parse and organize the data.
Start using the Tween 2 Module!