Following the trail… you have refreshCoins of type function, which is passed into showVungleAd as action.
This means action == refreshCoins == type is “function”.
So you can call it as action(), inserting params between the parenthesis if you need to.
Keep in mind that Lua only ever keeps one instance of a function in memory. When refreshCoins is passed into showVungleAd and picked up as the variable action, there is no copy of the function - it’s the exact same function as the original being called. (hope that made sense)
function showVungleAd(action) vungleAds.show( "incentivized" ) -- This is a call from third party plugin to deal with vungle ads action(params) end
Normally, you would link your adListener in the init() call to the Vungle SDK.
If you want multiple paths from the adListener - to award various outcomes then add that code into the adListener event.
local ads = require( "ads" ) local function adListener( event ) if event.type == "adEnd" then --call your function here refreshCoins() end end ads.init( "vungle", "myAppId", adListener ) ... sometime later ... ads.show( "incentivized" )
Following the trail… you have refreshCoins of type function, which is passed into showVungleAd as action.
This means action == refreshCoins == type is “function”.
So you can call it as action(), inserting params between the parenthesis if you need to.
Keep in mind that Lua only ever keeps one instance of a function in memory. When refreshCoins is passed into showVungleAd and picked up as the variable action, there is no copy of the function - it’s the exact same function as the original being called. (hope that made sense)
function showVungleAd(action) vungleAds.show( "incentivized" ) -- This is a call from third party plugin to deal with vungle ads action(params) end
Normally, you would link your adListener in the init() call to the Vungle SDK.
If you want multiple paths from the adListener - to award various outcomes then add that code into the adListener event.
local ads = require( "ads" ) local function adListener( event ) if event.type == "adEnd" then --call your function here refreshCoins() end end ads.init( "vungle", "myAppId", adListener ) ... sometime later ... ads.show( "incentivized" )