Advertisement

The dictionary class

Started by February 17, 2013 02:42 AM
1 comment, last by WitchLord 11 years, 9 months ago

Is it possible to have the dictionary in angelscript with a different syntax? The reason for this question is because I was originally going to use Lua in a project that I am working on, because I love its design in regards to its tables. They can be used as a means of doing configurations, but binding to a lua vm and then performing operations are mind boggling. Binding c++ to angelscript is what really won me over because it is pretty straightforward. Also because there is no vm to worry about because it just makes native calls.

However, I would like to also use angelscript as a configuration language if possible. Can there be lua like tables or something close to it ( the dictionary with some syntax sugar ).

dict = { ("one",1), ("object",object), ("handle",@handle) };

or

dict.set( ("one",1), ("object",object), ("handle",@handle) );

or

something

No.

Lua tables are the result of Lua being a prototypical language.

It's not possible to have dictionaries that hold varying types.

You can sort of emulate it with dictionary addon and any addon. Not pretty tho.

Advertisement

I also like the versatility of Lua's tables (though I've never used Lua myself). Unfortunately implementing something Lua's tables within AngelScript is not an easy task as they rely heavily on dynamic types, where-as AngelScript is statically typed. It can be done, but would require quite a few changes to the library.

Instead, may I suggest you take a look at XML for the data configuration, and then create and register an object for reading/interacting with the XML from the script?

The scripts can be placed as content of the XML (similarly to how javascript is often used embedded in HTML files). Or, you can have the XML nodes be content of the script files.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement