Call lua code from C++ code



In the GameAnalytics SDK native extension ( we a Remote Configs feature where the SDK gets the key/value pairs from our backend server after initializing the SDK. This means that the remote configs will first be populated after a second or two when getting the response back from our backend. Currently we just have a function called gameanalytics.isRemoteConfigsReady() which the developer can use to manually call to check if the remote configs are ready (have been populated). This is of course not ideal and we have now recently got users asking if it not possible to get notified when the remote configs have been populated.

So my question is how do I go about making a subscribe pattern in lua code which can then be notified by the native extension (c++ code). We have been able to do this in our Unity SDK and AIR SDK because they had some messaging system to be call from C++ code to script code if you understand. Is this possible in Defold or what is the best way to go about this? The SDK support both Android, iOS, Windows/OSX and web.

I look forward to hearing this is doable.

Lead SDK Developer @ GameAnalytics



Although we need to update our documentation with a better Lua callback example, we have several examples in our live code.

E.g. from extension-iap

Also see documentation for dmScript::CreateCallback() at al.

1 Like


Ok great thanks @Mathias_Westerdahl I will have a look at that.

1 Like

Gameanalytics Remote Config

Ok we have updated the GA SDK (v3.2.0) and it should now be possible to listen to when remote configs have been updated for all the platforms the extension support. Here is how to do it:


Gameanalytics Remote Config