Jump to content
  • Advertisement
Sign in to follow this  
PrincessDaisy

AngelScript over XML

This topic is 4590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently working on a project that involves using scripted data. The application does not need normal scripting features (function calls, objects etc.), instead it will be used solely to hold data. So for example, and effect script would just have information relating to the script, rather than any excessive function calls...
string particleTexture   = "effect.bmp";
string particleSize      = 10.0f;
And so on... My question is, is there any advantage in using AngelScript over XML? I really like the way XML can be displayed using a standard web browser, but on the other hand AngelScript is much easier to read from the source IMO. Is AngelScript going to be substantially slower than XML, or will there be no difference? Any opinions would be welcome Thanks Daisy

Share this post


Link to post
Share on other sites
Advertisement
Well first of all Angelscript was not designed for this.

But I think it will do it OK, although it won't be able to have estructured data easily (trees) unless you create objects for that. I think it is perfectly possible.

And the speed depends in the way the script is structured and the xml parser you compare it with.

This topic confronts me personally cause in my project I was going to use angelscript but ended switching to XML (tinyxml)

The reason was not because angelscript had any disadvantage, the thing is that I found that the game I was trying to remake had the attribute that its objects interacted which each others to form cool systems without the need of any scripted event (what I wanted to add to it)

I decided to respect that and just have a format that reads data and focus on making more objects that could help for interactions.

Well if on my next projects I need a scripting language for my levels I would use Angelscript for sure, but for plain data I preffered XML

But it is your program so it is up to you and if you find angelscript much easier to read go ahead.


---

I think though that for the data to interact with your program it would need to be like this:


options.particleTexture = "effect.bmp";
options.particleSize = 10.0f;

And you will need an options class in your app that is linked to angelscript

Share this post


Link to post
Share on other sites
The benefit of XML here is that you can make your levels using off-the-shelf XML editing products. You'd have to code up your own editor to get this sort of thing using AngelScript (or any other script language).

I can't imagine speed will be much different with either, except that the AngelScript version could potentially be compiled into bytecode for your release version meaning you miss out the parsing step. One thing that AngelScript (or another scripting language) does have over plain XML is that you can write logic in script which is very hard or cumbersome to do in XML. I've used both scripting an XML together in my projects, meaning that scripts can be attached to the XML or loaded by them which means you get the best of both worlds.

Share this post


Link to post
Share on other sites
Quote:
Original post by Vexorian
I think though that for the data to interact with your program it would need to be like this:


options.particleTexture = "effect.bmp";
options.particleSize = 10.0f;

And you will need an options class in your app that is linked to angelscript


I wouldn't need that at all. Each script would be an individual emitter, so having all the emitter information in one script, and then that information would be read in per variable in the code (every emitter would have the same information).

So that means I wouldn't need any object orientated code.

The reason I am asking is that I have used AngelScript before, and I do like it. But if using XML (which I havn't used before) makes more sense, then I will go in that direction.

@evolutional: I can still create my normal text editor program to create the scripts in the same way I would create the XML versions to.

Daisy

Share this post


Link to post
Share on other sites
I am saying it would have been much easier to access the members of a class that is on your app than browsing for all the variables in the stack and checking their names and values

Share this post


Link to post
Share on other sites
Quote:
Original post by Vexorian
I am saying it would have been much easier to access the members of a class that is on your app than browsing for all the variables in the stack and checking their names and values


That is true, but this is not the only way in which I will use it, and I want to keep a constistant interface.

When I come to localise my game, I will have all the strings in a script. Now I cant have an object in this situation, as I will no tknow how many strings I will have, or what their variable names are. If I am to use AngelScript, I will have a hugh list of strings, their ID, and the string they relate to.

In this case, AngelScript is much easier to read, and use (IMO), but slow?

Daisy

Share this post


Link to post
Share on other sites
Well, in my opinion AngelScript is not the way to go if you only need to store a lot of data. I did not design the library with this in mind, and do not think I will take it in that direction in the future either.

I'm a big fan of XML myself, and in my upcoming game project I intend to use XML for data and AngelScript for scripting.

If you want a consistent interface for both data and scripting then perhaps Lua would be what you're looking for. I do not have any personal experience with Lua however so I cannot say if this is true or not.

You mentioned that you'll make your game localizable and that you will store all the strings in the script, whether it be AngelScript or XML. May I suggest a simple text file instead. Your application would then read this text file and with an extremely simple parser store each of the strings in an internal structure. This would simplify both the file format and the application's interface for the scripts.

comparisons:

AngelScript

string str1 = "Hello";
string str2 = "Andreas";


XML

<strings>
<str id="1">Hello</str>
<str id="2">Andreas</str>
</strings>


Text file

1:Hello
2:Andreas


Which do you think is easiest to edit? Which would be easiest to load and access from the application?

Regards,
Andreas

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
If you want a consistent interface for both data and scripting then perhaps Lua would be what you're looking for. I do not have any personal experience with Lua however so I cannot say if this is true or not.


I'm not agree with this.
Xml can store both data and AS scripting. I've done it this way !

The Datas are stored in a normal XML way and Scripting is included through XML comment.

AbrKen.

Edit : Oops, the GD is deleting the XML comment !

Edit2 : After having VBScripting error I have removed the xml sample.

Share this post


Link to post
Share on other sites
That sounds like a good idea. But I have one doubt:

Can the XML comments include XML special characters like < > & " etc? Or do you have to escape them?

It probably can, since you're doing it like this.

By the way, to show XML examples you'll have to escape the characters that interfere with GameDev.net's HTML tags.

Regards,
Andreas

Share this post


Link to post
Share on other sites

Quote:
Original post by WitchLord
That sounds like a good idea. But I have one doubt:

Can the XML comments include XML special characters like < > & " etc? Or do you have to escape them?


You'd use CDATA sections in the XML to contain your script, this essentially tells the XML parser to 'switch off' parsing until the end of the CDATA section.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!