Archive 17/01/2023.

Creating custom component with Lua and AngelScript binding

slapin

Hi, all!

How can I create c++ component so that it is seen by both Lua and AngelScript?
I want to access some attributes and run some methods.

Eugene

You have to make script bindings. It’s pretty easy for AS and pretty hard for Lua if you don’t work in fork.

slapin

I do not work in fork, but I want these to be eventually integrated, so that should be no problem.
I currently work in separate project using Urho as library. I need to start with AngelScript.
How can I do this?

Eugene

Check files Urho3D/AngelScript/*API.cpp for examples

KonstantTom

It’s very easy to bind components from your downstream project to AngelScript, but it may not work when you link to Urho3D dynamically. Example from my project where I bind my Map component:
https://github.com/KonstantinTomashevich/colonization/blob/master/sources/Colonization/AngelScriptBinders/Core/BindMap.hpp
https://github.com/KonstantinTomashevich/colonization/blob/master/sources/Colonization/AngelScriptBinders/Core/BindMap.cpp#L30
You should run Bind{ComponentName} (script) functions on application startup.


slapin

Thanks a lot for the example!