Connecting database to TGB
by Retchel · in Torque Game Builder · 02/24/2010 (7:18 pm) · 18 replies
I have a problem regarding the connection of database to TGB. I used MySQl database to store the username and questions for the player. I have no idea how to connect MYSQL to TGB. Can you help me some concept or codes that can give me an idea?PLs...we have a project that should be pass next week.Thank you.
#2
02/24/2010 (7:47 pm)
Does Torque Game Builder supports MySQL database? Supposedly, our instructor have no idea about torque and actually we are the only one who choose to create games and my other classmates they create a system. I am reviewing some tutorials about torque and i have no tutorial in connecting database to torque..
#3
02/24/2010 (7:52 pm)
As I explained, it does not support it without getting into the source code, which you don't have access to. As a matter of fact, you said that you have the engine, but not through your school, and it does not show up in your account. How'd you get it?
#4
TGB comes with a built-in object called TcpObject. This object allows you to connect to a TCP connection and process text lines. You could make a simple TCP server in another language (C#, perhaps) and communicate easily from within TorqueScript.
This would let you do what you need without having the source code.
steve
02/25/2010 (12:14 pm)
I can think of a pretty easy way to do this, actually.TGB comes with a built-in object called TcpObject. This object allows you to connect to a TCP connection and process text lines. You could make a simple TCP server in another language (C#, perhaps) and communicate easily from within TorqueScript.
This would let you do what you need without having the source code.
steve
#5
Both methods will require some elbow grease on your part, but Stephen's is the simplest method as long as you know how to write a basic program that can access your database and listen on the TCP port.
02/25/2010 (1:56 pm)
To connect directly to the database from within TGB, you would need to implement a way to attach to ODBC data sources as Ted notes, and this would require the source code. Stephen also touched on a way that required an intermediary solution to parse your TcpObjects or HTTPObjects. You could do it in C#, Ruby, Python, Java, PHP, ASP, etc. To do that, you would need to create the intermediary solution.Both methods will require some elbow grease on your part, but Stephen's is the simplest method as long as you know how to write a basic program that can access your database and listen on the TCP port.
#6
02/25/2010 (9:27 pm)
If you do get the source, I found this video guides you step by step on how to build mySQL into a project. Granted, the video is for T3D, it was virtually the same for TGB
#7
03/01/2010 (6:12 pm)
Thank you for the source but i was doubted where should i put that code, in a .gui form or .cs form and how would i know that is being connected to mysql.Thank you
#8
Since you are using the demo version, you can only use the scripts, which as Stephen Nichols said above in post #4, you can achieve using a TCPObject. That's the only way to do it without source (of course, not having a license at all, I don't know if the demo is limited from doing that- if you're going to get that deep into the project with TGB, why not just buy a license?).
03/01/2010 (6:44 pm)
That video is a guide to setting up a resource for which you need source code access.Since you are using the demo version, you can only use the scripts, which as Stephen Nichols said above in post #4, you can achieve using a TCPObject. That's the only way to do it without source (of course, not having a license at all, I don't know if the demo is limited from doing that- if you're going to get that deep into the project with TGB, why not just buy a license?).
#9
03/02/2010 (10:31 pm)
What is TCPObject and what is the functionality of that?
#10
03/02/2010 (11:49 pm)
Should i use the TCPObject inorder to connect ob MYSQl?i dont want to publish my game in online game. i was created this for stand alone only?
#11
Was it a requirement to store these in MySQL? Could you simply use files? If so, you can use the built-in FileObject to get and write usernames/questions.
If not, you'll have to go with what everybody else is describing. Create a stand-alone program that listens on a port. This stand-alone program runs on the same machine that the game does, connects to the database, listens for messages, and returns results after processing each message. You'll just use the TCPObject to connect to the local port, send messages, and listen for results.
If you only have 2 days left, I'd seriously consider faking it with files. That is, unless you have a lot of free time to write a program.
03/03/2010 (12:40 am)
You state:Quote:I used MySQl database to store the username and questions for the player.
Was it a requirement to store these in MySQL? Could you simply use files? If so, you can use the built-in FileObject to get and write usernames/questions.
If not, you'll have to go with what everybody else is describing. Create a stand-alone program that listens on a port. This stand-alone program runs on the same machine that the game does, connects to the database, listens for messages, and returns results after processing each message. You'll just use the TCPObject to connect to the local port, send messages, and listen for results.
If you only have 2 days left, I'd seriously consider faking it with files. That is, unless you have a lot of free time to write a program.
#12
03/03/2010 (2:14 am)
I ask our instructor if only the username and the score of the player will be stored in the database and she said thats its okay. She said that it should be an actual database not an flat file database. Can you give someidea how to implement a TCPObject and connect it to the server and mYSQl database?Thank you
#13
03/03/2010 (9:52 pm)
Does tutorial in torque game builder in requesting username or name of the player is consider as flat file database?
#14
With everybody's response, it seems like there is more than enough information to proceed.
I found this tutorial on TCPObject. I think it's all still valid. Best of luck!
realmwars.feylab.com/tutorial/Tutorial1.htm
03/03/2010 (11:37 pm)
There might be a language barrier, but I'm not certain I understand your last question.With everybody's response, it seems like there is more than enough information to proceed.
I found this tutorial on TCPObject. I think it's all still valid. Best of luck!
realmwars.feylab.com/tutorial/Tutorial1.htm
#15
03/05/2010 (12:21 am)
Is this TCP Object for Torque Game engine is the same with the implementation for Torque Game Builder?Thank you for the tutorial you've been given. it helps me a lot..
#16
03/05/2010 (12:47 am)
Yep, it is.
#17
03/12/2010 (8:26 pm)
You could tell your instructor that you'd prefer to use a dBase IV database. It's basically a tab-delimited file with the top row saving the column names. It'd be easy to write by hand, access from within Torque and your instructor, if so inclined, can connect to it via ODBC. You could even write a quick little database viewing application in C++ or C# or Java (JDBC) to prove it's a legitimate database file.
#18
03/14/2011 (9:31 pm)
Retchel, are you manage to connection with MYSQL?
Torque 3D Owner Ted Southard