modding the engine
by Gary Roberson · in Torque Game Engine · 01/14/2010 (10:49 pm) · 5 replies
Even though I am a strong disbeliever in modding the engine as many torquers would strongly discourage me from doing, it seems the time has come for me to do so.
simply, I need to add a database to my project.
If i can't find one, i plan on writing one using Visual C++ 2005.
My question is, once I have one done, how do I tell the engine that it is there!
simply, I need to add a database to my project.
If i can't find one, i plan on writing one using Visual C++ 2005.
My question is, once I have one done, how do I tell the engine that it is there!
About the author
#2
The question you should be asking yourself is "why do I need a database?" and "Why do I need to reinvent the wheel?" and "Is what I need really a database?"
The only reason you need a database is if you're writing an MMO, persistent online world or business application. Most other needs can be met with binary files or xml. If you really need a datbase you probably should be looking at tinySQL or mySQL, but I suspect you don't need a fully fledged database.
What do you want to do that the engine doesn't do now?
How you tell the engine about the database depends on what you're trying to achieve. Most of the time you only need to use it from your own extensions to the source.
01/14/2010 (11:41 pm)
I wouldn't discourage you from modding the engine at all, that's silly advice. You have the engine source so that you can mod it freely, as much as you like.The question you should be asking yourself is "why do I need a database?" and "Why do I need to reinvent the wheel?" and "Is what I need really a database?"
The only reason you need a database is if you're writing an MMO, persistent online world or business application. Most other needs can be met with binary files or xml. If you really need a datbase you probably should be looking at tinySQL or mySQL, but I suspect you don't need a fully fledged database.
What do you want to do that the engine doesn't do now?
How you tell the engine about the database depends on what you're trying to achieve. Most of the time you only need to use it from your own extensions to the source.
#3
01/15/2010 (1:51 am)
Quote:Even though I am a strong disbeliever in modding the engine as many torquers would strongly discourage me from doingDon't let the bastards grind you down! (No offence to anyone out there, I just love that phrase ;).) You paid for the source code - it's a waste not to use it. There is a time and a place for scripting things, but sometimes you just have to get your hands dirty.
#4
Oh oh oh... this is a dangerous statement.
This reminds me of some statements to push Torque3D (not T3D Pro).
First you have to know which type of database you need. A local database or a online database.
Do you have to handle a huge amount of data? In this case you should think about multithreading.
You have to handle three parts. The engine, the database and wrapper-functions.
First you need some ConsoleFunctions. A ConsoleFunction is some kind of bridge between TorqueScript and the 3D-Engine.
Example: AddSomeDataToDB("some data"); // in TorqueScript
The ConsoleFunction in C++ should look like that:
But where do you have to write mysql_add(...) ? Well, this is the harder part. You can write these functions into the Torque-C++-Project or you can append a DLL.
In my case i only write the ConsoleFunctions into the Torque-Project. All the other (more interesting) functions are accessible with a DLL.
01/15/2010 (6:20 am)
Quote:
Even though I am a strong disbeliever in modding the engine as many torquers would strongly discourage me from doing, ...
Oh oh oh... this is a dangerous statement.
This reminds me of some statements to push Torque3D (not T3D Pro).
Quote:
simply, I need to add a database to my project.
First you have to know which type of database you need. A local database or a online database.
Do you have to handle a huge amount of data? In this case you should think about multithreading.
Quote:
My question is, once I have one done, how do I tell the engine that it is there!
You have to handle three parts. The engine, the database and wrapper-functions.
First you need some ConsoleFunctions. A ConsoleFunction is some kind of bridge between TorqueScript and the 3D-Engine.
Example: AddSomeDataToDB("some data"); // in TorqueScript
The ConsoleFunction in C++ should look like that:
ConsoleFunction(AddSomeDataToDB,bool,2,2,"description of the function")
{
const char* theData = Con::getReturnBuffer(dStrlen(argv[1])+1);
theData = argv[1]; //the first given parameter from AddSomeDataToDB
// here you would call a function to add the data to a db table
// maybe:
return mysql_add(theData);
}But where do you have to write mysql_add(...) ? Well, this is the harder part. You can write these functions into the Torque-C++-Project or you can append a DLL.
In my case i only write the ConsoleFunctions into the Torque-Project. All the other (more interesting) functions are accessible with a DLL.
#5
Thanks, you are a great help and timesaver!
@Mr. Trent
Well, I'm not doing an MMORPG, but an RPG nonetheless. the database is for storing such things as charater stats, inventory, weapons, armor, and such. Yeah, I know what I'm doing, just don't know how!
@for the rest of you!
I guess its a aconfusion in terminology. I said "database", did I mean to say "database functions" or "database files". Do we really need to be so picky!
01/15/2010 (8:41 pm)
@Mr. RowleyThanks, you are a great help and timesaver!
@Mr. Trent
Well, I'm not doing an MMORPG, but an RPG nonetheless. the database is for storing such things as charater stats, inventory, weapons, armor, and such. Yeah, I know what I'm doing, just don't know how!
@for the rest of you!
I guess its a aconfusion in terminology. I said "database", did I mean to say "database functions" or "database files". Do we really need to be so picky!
Torque Owner Mike Rowley
Mike Rowley
Simple search of the forum turned up this thread. It may help.