-
Notifications
You must be signed in to change notification settings - Fork 403
Native Scripting
See LiveCode for easy C++ scripting with latest engine versions.
Following is only for the old version of the engine (with Qt-based editor)
The script system is a plugin for LumixEngine and is based on runtime-compiled C++. A Visual Studio solution containing all the scripts is generated and compiled in runtime. Resulting DLL is then loaded. The generated solution can be opened in Visual Studio by clicking on button "Open In VS". Any of the scripts can be opened in VS by doubleclicking on it in the list of scripts.
Since scripts can access engine functions, it is necessary to have a source code of engine and to set path to it in the Script compiler window. LumixStudio expect Visual Studio to be installed in one of the standard paths, which are defined in scripts/compile_all.bat. This batch file is executed to compile the solution.
When DLL is loaded the system looks for following functions:
- extern "C" DLL_EXPORT void serialize(Lumix::OutputBlob& blob)
- extern "C" DLL_EXPORT void deserialize(Lumix::InputBlob& blob)
- extern "C" DLL_EXPORT void update(float time_delta)
- extern "C" DLL_EXPORT void init(Lumix::ScriptScene* scene)
- extern "C" DLL_EXPORT void done()
Serialize/Deserialize
functions are used to seamlessly reload scripts. Init
function is called after the library is loaded. update
is called each frame. And finally done
function is called once we want to unload the library.