Archive 17/01/2023.

Event in angelscript

rifai

Where I can find list of all inbuilt angelscript event (update, postupdate, etc) ?
I can find C++ event in header files xxxxEvents.h.

Can I “register” my custom C++ event and using it from angelscript?

friesencr

Reference is in the script documentation.
github.com/urho3d/Urho3D/blob/m … API.dox#L6

You can use your own events. Events are more or less a stringhash(a 32bit integer) with a stringhashmap of event parameters. The code in c++ that registeres them in object.h:

#define EVENT(eventID, eventName) static const Urho3D::StringHash eventID(#eventName); namespace eventName
#define PARAM(paramID, paramName) static const Urho3D::StringHash paramID(#paramName)

they reserve and make a constant of the names to minimize memory usage and increase performance.

On the script side you can either give a string or a stringhash. the string will be converted to a stringhash.

weitjong

All the inbuilt events are listed in urho3d.github.io/documentation/H … _list.html.

You don’t actually “register” your own events in C++ in order to expose them to AngelScript and Lua. Your C++ class just send those custom events in your code at the point where they are desirable. Your script can subscribe to the new custom events just as if they are other inbuilt events.

rifai

Thanks. I got it.