some general questions

Started by
6 comments, last by WitchLord 18 years, 8 months ago
hi, I've got some general questions about angelscript: 1. can you load/save compiled versions of a script? if so, how? 2. are there any build in functions/classes or do you have to register every class/function yourself. 3. does it support unicode (the interface and the scripting language)? 4. if you register want to register a c++ class, do you also have to register all private members or is this or is this not possible/required/suggested? I've you don't understand what I mean, feel free to ask (I'm not a native english speaker -> german). I'm sorry if this information is in the documentation, I didn't find it. cu blueprogrammer
Advertisement
1. Yes, look up SaveByteCode and LoadByteCode from here: http://www.angelcode.com/angelscript/sdk/docs/appmanual/pages/ref_engine.html

2. No, a std::string binding is given in a few ways and so is std::vector, the rest is up to you.

3. Not sure about unicode

4. You cannot to my knowledge register private data. You are only required to register an object type and any public methods you wish to expose. You do not have to register all public methods or properties, only those you wish. Also, if you wish to have a script instantiate these objects, you will need to register constructor/destructor. A templated example can be found here: http://www.gamedev.net/community/forums/topic.asp?topic_id=316064

Also, if you plan to use references, you need to register addref/release behaviours for the object.
Hi blueprogrammer,

1. Yes, you can. Use the methods SaveByteCode()/LoadByteCode().
2. Not really, there are script structures, arrays, and the any type. But all other object types and functions has to be registered by the application, including the string type. Take a look at asCScriptString (in the add_on directory), for an idea on how types are registered.
3. Unicode is not yet supported.
4. You choose which members to register, the scripts will only be able to use the members you have registered. It is possible to register private members but not recommended, as they wouldn't be private if you did so. Again, look at the asCScriptString, for an idea on how types are registered.

Feel free to ask anything you want. The library documentation has most of the information, but I know that it may not always be easy to find all the necessary information. Once the library stabilizes some more, I'll work on fleshing out the documentation with better descriptive texts and not just an API reference.

Regards,
Andreas




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

As for 3, you can always try to use utf8 instead of wide character unicode. As utf8 is compatible with ascii strings, there's a big chance it works without changes. To/from the scripting engine you can use MultiByteToWideChar and WideCharToMultiByte to convert to and from utf8.
hi,

thanks for the fast replies.

to point 1:
I've got a question about your interface/code design: why do you use the class asIBinaryStream for SaveByteCode()/LoadByteCode(), but for AddScriptSection() you use a simple pointer to the data. Seems to me a little bit inconsistent. I would delete the asIBinaryStream (if it is only used in SaveByteCode()/LoadByteCode()) and use a simple pointer to an array with the data. I'm sorry if I missed something important here.

to point 4:
If you do not register the private members how does the script know the size of the object (when allocating memory and constructing the object)?

What are these code "sections" in AddScriptSection()? I didn't get the point. Are global/local data/funtions shared between "sections" or what is it used for?

cu blueprogrammer
is there an ide for angelscript?
RainDog has a sort of IDE he's working on, but AFAIK it's rather domain-specific. You might be able to convince him to fork out a general purpose version.

Otherwise, you can edit angelscript in Visual Studio or whatever IDE you use. Just give your scripts an extension it knows how to parse. I use .c myself. You can even get intellisense. In every angelscript file, I include a header called 'vsintellisense' that includes declarations of everything bound to the script. It's setup to preprocess to an empty file when compiling in angelscript. Of course that requires using a preprocessor with angelscript.
1. I hadn't really thought about it before. The initial support for saving/loading bytecode wasn't implemented by me, so I kind of accepted the contribution as it was without changing it.

I'll give it some more thought. Maybe I'll do some changes. Thanks for pointing that out to me.

4. The size of the object is known from RegisterObjectType() where the second parameter is the size of the object, you should use the sizeof(type) operator to determine this value. For most classes you should also register a constructor, which will do the initialization of the members, so the script library doesn't have to know about them.

You can think of script sections as separate files. But all script sections added to the same module share the same scope, so functions/variables/types declared in one section is available in the other ones as well. All declarations are order independent, so you don't have to register the sections in any specific order.

To the library, it doesn't make a difference if you add two sections or if you first concatenate them and add them as one unique section. However, error messages report the script section name, so that can be used to make it easier to find the origin of the error.

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