XML reader (or other text parser) for TGB?
by AzraelK · in Torque Game Builder · 09/26/2006 (1:28 pm) · 7 replies
I want to be able to load data for my game (specially text) from XML or similar text files, since Im working in an adventure type game (where you can choose an answer in a conversation) , theres going to be a lot of text to proof read and check sintax, so I want the format to be as unrestrained as possible to modify.
Has anyone tried to do something like this before? or is there any built in functionality to do this?
Has anyone tried to do something like this before? or is there any built in functionality to do this?
#2
09/27/2006 (8:13 am)
If you have a Pro license, you could look at integrating TinyXML into the TGB source.
#3
Just as an example Im trying to do something like Kotor but in 2d and Without Jedi Knights (yeah I know we will miss the jedis dont worry we will replace with Ninjas or something)
Philip: No, unfortunately I dont have the Pro license, (curious because I did had the TGE source code along with my old TGE license, oh well)
09/27/2006 (9:05 am)
Thanks Alex. But could you quote an specific example please? Im planning to put a good portion of written text so it has to be pretty well organized. (thats why XML was my first choice) Just as an example Im trying to do something like Kotor but in 2d and Without Jedi Knights (yeah I know we will miss the jedis dont worry we will replace with Ninjas or something)
Philip: No, unfortunately I dont have the Pro license, (curious because I did had the TGE source code along with my old TGE license, oh well)
#4
09/27/2006 (9:24 am)
There is not currently a way to read and parse XML without incorporating source changes. You could use the stream functions in TorqueScript to do it, though. You would have to write it all from the ground up. But if you released it as a resource, I could point to it in six months when someone else asks if it can be done. :)
#5
Could somone point me to a good example to read data from a streams and showing it in a GUi?
09/27/2006 (9:34 am)
Thanks David, but I think at the time I could just use the streams, maybe later I could do a xml reader resource, (although it would be slow Im afraid) Could somone point me to a good example to read data from a streams and showing it in a GUi?
#6
09/27/2006 (10:28 am)
One of the great things about XML is that it's so easy to parse. You could easily write a parser in TorqueScript (in other words, no need for a pro license to accomplish this). If you get stumped, check out this page about creating a parser in PHP.
#7
1. Prefs.cs shows a method of how to get strings into global variables. That's an easy way to get lots of text into variables. You just exec() the file and your text or other settings are loaded. Not great formatting and not good for lengthy text, but super easy.
2. Torque platform , including TGB, supports an html-like text markup language (.hfl extension). For example install the TGE demo and look in Torque Game Engine Demo\common\help. You will see a bunch of .hfl files that use a pseudo-html markup that can be displayed in gui controls. This is built-in to the engine.
3. Just write .txt files and read them into a variable at runtime via torquescript.
I am just skeptical that writing an XML parser is really necessary or useful for many types of games. There are lots more interesting game development tasks to do than write a XML parser :-)
09/27/2006 (10:53 pm)
@AzraelK, Here are some ideas1. Prefs.cs shows a method of how to get strings into global variables. That's an easy way to get lots of text into variables. You just exec() the file and your text or other settings are loaded. Not great formatting and not good for lengthy text, but super easy.
2. Torque platform , including TGB, supports an html-like text markup language (.hfl extension). For example install the TGE demo and look in Torque Game Engine Demo\common\help. You will see a bunch of .hfl files that use a pseudo-html markup that can be displayed in gui controls. This is built-in to the engine.
3. Just write .txt files and read them into a variable at runtime via torquescript.
I am just skeptical that writing an XML parser is really necessary or useful for many types of games. There are lots more interesting game development tasks to do than write a XML parser :-)
Torque Owner Alex Rice
Default Studio Name