[New feature] Angelscript support (was Lua support)

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 20 Aug 2011, 19:53

Yeah, seems to be float. But this wans't the problem as I just fount out:
It had nothing to to with the types. I simply declared the function to AS in a wrong way:
getMoveSpeed() returns a "const float&", but to AS I was telling it returns a "float".

By the way, I will soon push a new commit that already makes use of AS ("exit" and "movespeed" commands). I changed the old command interpreter to return a bool instead of a void, this way I can toggle to the AS interpreter if the command is not hardcoded. So, in the next time more and more commands will be executed by AS.

This also mean: From now on, for Releases, we will have to ship the /scripts folder with its content!

The full conversion will take a while, I fear. Especially the gameMap object needs some refactoring to be efficiently used by AS. Also it seems I need to register some Ogre functions (like Ogre::Degree for example).

edit: Pushed!
StefanP.MUC
 

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 21 Aug 2011, 15:46

Just a quick notice:
http://code.google.com/p/ogre-angelscript/ (Ogre-AS binding)
is done by the Rigs of Rods team, they use AS as Ogre in their game, too. I think it's worth keeping an eye on it.
StefanP.MUC
 

Re: [New feature] Angelscript support (was Lua support)

Postby oln » 21 Aug 2011, 16:41

Yeah, I've looked at the Rigs Of Rods source for inspiration a few times as well.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 22 Aug 2011, 20:05

Just updated AS to the new Bugfix release.
StefanP.MUC
 

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 30 Aug 2011, 17:09

Just pushed a big commit to the ASWrapper. I registered the GameMap class and also converted one command, it should now go rather quick converting the rest of the commands, too, because it basically comes down to copy'n'paste now that I have used most of the AS functions at least once.

I also introduced a templated wrapper class that saves a lot of work with the handle managment of AS.

What else is on the plan? I figured out that AS also supports implicit conversions in the scripts (for example: 4 + "5" = 9, so int + string = int), but I haven't got it working. I think this will be a nice feature for script writers.

By theway, in teh ASWrapper.h/cpp I also tested the 100 char limit + table align on declaration lists.
StefanP.MUC
 

Re: [New feature] Angelscript support (was Lua support)

Postby oln » 30 Aug 2011, 17:22

I think we should try to make the player AI's scriptable. E.g having an ai sub-class (of BaseAI) which takes a script filename or similar as a parameter.
The AI is meant to access everything through the AIWrapper class. (Which is very basic right now.)
How does the object mapping between AS and C++ work? Can you run a script with an object as a parameter, or would one have to register the list of AI instances and pick the right one in the individual scripts?
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 30 Aug 2011, 18:08

You register a type, e.g. a class and then you register the members of this class that should be visible to the script engine. Then AS can directly work with objects of this type.

It's possible to register the whole AIWrapper class including all its members. Then the script writers can create instances of it from within the script code and use it like they would use it in C++.
StefanP.MUC
 

Re: [New feature] Angelscript support (was Lua support)

Postby oln » 30 Aug 2011, 18:19

The thought was more to have the script access an aiwrapper instance that is bound to the ai instance, rather than to create it inside the script. (Or is there a better way?)
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [New feature] Angelscript support (was Lua support)

Postby StefanP.MUC » 30 Aug 2011, 18:41

If the AIWrapper class is registered than the script can access any instance of this class if we allow it.

I think we have (almost) no limitations with AngelScript. It can access everything we want it to access. And also the other way round: We can pass whatever we like to Angelscript (we only need to tell AS that the type exists, because all AS is basically doing internally is moving pointers to C++ objects and functions around). Directly passing stuff from C++ to Angelscript is a bit harder than passing stuff from AS to C++ or retrieving stuff from C++, however. So, if possible, we should provide a getter function in C++ and register it to AS. Then AS can fetch this object and do everything we like with it. This can, of course, also be an AI class of any type.

After I converted the commands to AS I'll have a look at your AI classes.
StefanP.MUC
 

Who is online

Users browsing this forum: No registered users and 1 guest