• Advertisement
Sign in to follow this  

The dictionary class

This topic is 1798 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

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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.

Share this post


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

  • Advertisement