Need scripting advice for my project

Started by
26 comments, last by Diodor 19 years, 6 months ago
Quote:Original post by evolutional
That often seems to be the typical anti-Xml argument, that all tags need entering twice. That's only true if the tag is a container element for other elements. Even then, the amount of time you'd be hard coding the xml will be minimal if you create a tool to edit your content. Xml has the benefit of being hand tweakable too.


Let's leave the tools out - making them costs time and makes the data format unflexible. Not having to use tools other than a text editor is a strong point of data description languages, compared to binary formats.

For instance, let's compare how one would describe a set in lua and in XML:
--luaset={1,2,5,12,"foobar",20};XML<set><element>1</element><element>2</element><element>5</element><element>12</element><element>foobar</element><element>20</element></set>


Quote:Xml doesn't pretend to be a scripting language and hence shouldn't have the capability of Lua


XML in facts pretends to be nothing useful at all. It doesn't even has separate types for numerical values and strings. To get to do anything at all with XML you have to either write extra code or start shopping for tools and extensions, from DTD to Schema to XSLT to Xwhatever (== work).

Quote:As ever, I'm inclined to argue the case for using both as I believe they can both be used together sucessfully, however as other have pointed out there are solutions availbale using one or the other, I guess it's up to your development team and game as to which one of the solutions you take.


My point is that a scripting language and a data description languages are both useful in a program, but lua _is_ both to begin with. It's better than xml at plain data description and it's that much better because one can mix data description and code in various ways.
Advertisement
Wow, it seems I've sparked quite the debate. There have been so many good arguments made for both sides that I honestly can't say that I'm closer to a decision than I was before. But I can say that I feel much more comfortable with the knowledge that both parties can be used effectively. I feel like a kid in a ice cream store trying to choose between vanilla and chocolate, lol. Thanks for all the responses and constructive arguments everyone.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

Quote:Original post by evolutional
A valid point, however I doubt people would create their entire game's level content in Lua, for that you'd need a data container such as a custom file format or Xml. The benefit of Xml is that parsing it is trivial with the plethora of good libraries out there.


Of course, but that's not a benefit over Lua (if already embedded) because Lua not only provides the parser but the way to get that data into internal structures. Assuming the internal game data is going to be reflected into Lua for scripting purposes anyway, you've essentially got all your parsing and assigning pre-written. That wouldn't be the case with any XML parser in C or C++, where you're going to need to write functions to map entities to objects and attributes to member variables purely for loading and saving purposes, when all this has already been done for the Lua interface.

If Lua wasn't already part of the system I would consider XML to be an equally attractive option.

Quote:Original post by Diodor
Let's leave the tools out - making them costs time and makes the data format unflexible.


Quote:Original post by Kylotan
Assuming the internal game data is going to be reflected into Lua for scripting purposes anyway, you've essentially got all your parsing and assigning pre-written.


Using the example cited by Diodor, in a purely Lua vs Xml contest it's obvious that Lua would win as it's more than Xml claims to be. Lua is a runtime scripting language as well as a data description language, Xml is a meta language for describing data. However, what sort of development environment wouldn't use external tools? When you start to bring in such tools as level editors and modellers you begin to open up more and more uses for Xml for describing data, especially when the external tools need to perform trasnformations on that data or parse it when a Lua environment doesn't exist.


Quote:Original post by Roots
But I can say that I feel much more comfortable with the knowledge that both parties can be used effectively. I feel like a kid in a ice cream store trying to choose between vanilla and chocolate


To me this comment sums up the whole debate.

I have never once argued that you should not use Lua, nor said that you should use just Xml. I've argued that both systems have their merits and it's possible to use them both in combination and I still hold to that fact.

Xml and Lua are what you make of them and what you make of them is entirely down to personal choice.

[smile]
the nice thing about Lua is that it can be compiled to byte code. so it *should* be faster than XML. I don't know for sure. I keep my scripts in their ASCII form. Additionally, you can use Lua as a config file. If you want, i could give ya the code that uses the LUA VM to parse the lua script directly.

So something like this:

Engine={
UseHWSkinning=true,
UseHWVP=true
}

you could get these attributes from the script fairly easy.

Btw, someone suggested Simkin scripting language above. Well, i;ve had the misfortune to work on a game that used Simkin. it didn't use the XML component however- it just used it as a script language. Simkin is the worst script language I have ever seen. it crashes pretty often and is really really incomplete. For instance if a designer wants to store a reference to an object in his script to a treenode- they can;t do this unless an engineer adds this capability to it.

Once again i want to emphasize we didn't use the XML component of simkin though. My advice to you is that whatever you pick, make sure it's something that's proven and has been around. That might help reduce risk.
Quote:Original post by evolutional
However, what sort of development environment wouldn't use external tools? When you start to bring in such tools as level editors and modellers you begin to open up more and more uses for Xml for describing data, especially when the external tools need to perform trasnformations on that data or parse it when a Lua environment doesn't exist.


When you say tools, do you mean tools written by the developer or general use tools available for XML-based solutions?

If it's the former, I stand by Lua - Lua scripts can easily parse, transform and serialize data. Not knowing much about the XML way, some examples of things XML could do better than Lua may further the debate.

EDIT: [smile]

[Edited by - Diodor on September 20, 2004 1:32:43 AM]
From what I've heard open source XML parsers are "meh", but I have no idea.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

Quote:Original post by Roots
From what I've heard open source XML parsers are "meh", but I have no idea.


TinyXML is my choice of Xml parser. Small, lightweight, stable and pretty quick. It doesn't have any of the extra stuff such as Validation, XSLT, XPath or XQuery though, as it's mainly just a quick parser for grabbing Xml data into your program. If you need other features, I believe that libXml2 has them (or at least ways of adding them).

C# an .NET languages also have access to Microsoft's optimised Xml classes, so if you're using a .NET language you have support already built in.


Quote:Original post by Diodor
Not knowing much about the XML way, some examples of things XML could do better than Lua may further the debate.


I'm not really one for 'vs' debates; but Xml and Xml technologies are foundation to technologies such as SOAP and .NET web services, they can also be used in many back-office scenarios from data exchange (think legacy EDI systems) and data querying. Xml also powers many websites (including this one [wink]) because of it's flexibility.

Being a web systems programmer and data analyst it's hard for me to ignore Xml in all of it's forms, it is a logical conclusion that it can be used in games - and it is, my games use it extensively as do several hobby games I've seen (don't ask me about commerical games as I seldom play them). A lot of my work/research lately is about bolstering games with scripting technologies and Xml, granted I'm not using Lua in this. Lua could probably do all that and more given the chance, I'm not saying it couldn't - I'm just saying that there is another way which is what I was trying to show the OP.

Lua and Xml are what you make of them, that's the crux in this matter. It's not what you use, it's how you use it.

Quote:Original post by Roots
From what I've heard open source XML parsers are "meh", but I have no idea.


Since I've been the one inside the project pushing lua, I'll respond by saying that the open source xml parsers are flakey and generally slow. I can back this up with empircal data, but I'm really lazy at the moment.

The big advantage to Lua is that if we were to define data, that data would not necessarily be static. Wherein some xml data file you'd have to hand edit a bunch of crap to make a big system wide change, you can dynamically do things in lua, do calculations at runtime, etc. It allows the application to be extendable in an insane number of ways.

Also, lua allows things like dictionaries and other data structures to be created to store the data - data structures which are much harder to manage and utilize properly when written strictly in c.

This in turn allows the data to be passed to c in a single simplified way with an underlying structure which could be quite advanced. Lua simplifies this all.

Unlike using xml, lua also allows things like great regular expression searching and such. I know there are c libraries, but this just adds to the complexity of the application. Lua will take care of all of this and more, while allowing true extendability within the application itself.

On top of that, I'm one of the developers on the project and I know lua pretty damned well :P. So there's that advantage to using lua.

---michael bernsteinmichael@simoniac.com
Quote:Original post by Diodor
Quote:Original post by evolutional
That often seems to be the typical anti-Xml argument, that all tags need entering twice. That's only true if the tag is a container element for other elements. Even then, the amount of time you'd be hard coding the xml will be minimal if you create a tool to edit your content. Xml has the benefit of being hand tweakable too.


Let's leave the tools out - making them costs time and makes the data format unflexible. Not having to use tools other than a text editor is a strong point of data description languages, compared to binary formats.

For instance, let's compare how one would describe a set in lua and in XML:
*** Source Snippet Removed ***

Quote:Xml doesn't pretend to be a scripting language and hence shouldn't have the capability of Lua


XML in facts pretends to be nothing useful at all. It doesn't even has separate types for numerical values and strings. To get to do anything at all with XML you have to either write extra code or start shopping for tools and extensions, from DTD to Schema to XSLT to Xwhatever (== work).

Quote:As ever, I'm inclined to argue the case for using both as I believe they can both be used together sucessfully, however as other have pointed out there are solutions availbale using one or the other, I guess it's up to your development team and game as to which one of the solutions you take.


My point is that a scripting language and a data description languages are both useful in a program, but lua _is_ both to begin with. It's better than xml at plain data description and it's that much better because one can mix data description and code in various ways.



exactly. with lua, you are able to add logic in with the data rather then just having static data. people could add/change functionality in the game to suit their own tastes (as seen with homeworld 2) via lua. there are a TON of examples of lua being a successful scripting/data description language in gaming.

Monkey Island, Baldurs Gate (which has a lot lot lot of weapon/monster/etc type of data, similar to the data we'll be dealing with), Homeworld 2, Mythica (which was cancelled, not due to quality or because of lua), and many many others.

Not many to my knowledge embrace xml.
---michael bernsteinmichael@simoniac.com

This topic is closed to new replies.

Advertisement