Strange, if i paste this code straight, not in function, it works…
local delegate = { didFailToLoadInterstitial = function(location) print("Chartboost: didFailToLoadInterstitial " .. location); print("Reload stuff") local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then circle.alpha=0 black.alpha=0 end end end print("No connection") -- Show alert with two buttons native.showAlert( "Магазин", "Ой! Нет рекламы для показа! Попробуйте позднее!", { "OK" }, onComplete) return end, didCloseInterstitial = function(location) print("Chartboost: didCloseInterstitial " .. location); circle.alpha=0 black.alpha=0 return end, didClickInterstitial = function(location) print("Chartboost: didClickInterstitial " .. location); local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then absinth:set("absinth", "yes") absinth:save() circle.alpha=0 black.alpha=0 rectMask.x = -7000 rectMask.y = -7000 director:changeScene("shop", "fade") end end end print("No connection") -- Show alert with two buttons native.showAlert( "Магазин", "Удачи с Вашей новой бутылкой!", { "OK" }, onComplete) return end } -- Initialize Chartboost cb.create{appId = "5236c2b916ba47f46c000000", appSignature = "42a9b0ebb706fcc41059821e5c18e028adcede47", delegate = delegateChart, appVersion = "2.01", appBundle = "com.entailstudio.twist"} cb.startSession() cb.cacheInterstitial() function chartboost\_show\_ad() if cb.hasCachedInterstitial() then msg = "Chartboost: Loading Interstitial From Cache" end print(msg) cb.showInterstitial() return true end chartboost\_show\_ad()
But when i insert this in my code, it will never fire
local absinthFunc = function(event) if event.phase == "moved" then local dy = math.abs( ( event.y - event.yStart ) ) -- If our finger has moved more than the desired range if dy \> 10 then -- Pass the focus back to the scrollView scroller:takeFocus( event ) end end if event.phase == "ended" then circle.x = absinthBot.x circle.y = absinthBot.y circle.alpha=1 audio.play( tapsound, {channel=2}) local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then if require("socket").connect("google.com", 80) == nil then local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then circle.alpha=0 end end end print("No connection") -- Show alert with two buttons native.showAlert( "xx", "xx", { "OK" }, onComplete) else local delegate = { didFailToLoadInterstitial = function(location) print("Chartboost: didFailToLoadInterstitial " .. location); print("Reload stuff") local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then circle.alpha=0 black.alpha=0 end end end print("No connection") -- Show alert with two buttons native.showAlert( "xx", "xx", { "OK" }, onComplete) return end, didCloseInterstitial = function(location) print("Chartboost: didCloseInterstitial " .. location); circle.alpha=0 black.alpha=0 return end, didClickInterstitial = function(location) print("Chartboost: didClickInterstitial " .. location); local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then absinth:set("absinth", "yes") absinth:save() circle.alpha=0 black.alpha=0 rectMask.x = -7000 rectMask.y = -7000 director:changeScene("shop", "fade") end end end print("No connection") -- Show alert with two buttons native.showAlert( "xx", "xx", { "OK" }, onComplete) return end } -- Initialize Chartboost cb.create{appId = "5236c2b916ba47f46c000000", appSignature = "42a9b0ebb706fcc41059821e5c18e028adcede47", delegate = delegateChart, appVersion = "2.01", appBundle = "com.entailstudio.twist"} cb.startSession() cb.cacheInterstitial() function chartboost\_show\_ad() if cb.hasCachedInterstitial() then msg = "Chartboost: Loading Interstitial From Cache" end print(msg) cb.showInterstitial() return true end chartboost\_show\_ad() end end end end -- Show alert with two buttons native.showAlert( "xx", "xx", { "OK" }, onComplete ) elseif 2 == i then circle.alpha=0 end end end -- Show alert with two buttons native.showAlert( "xx", "xx", { "xxx", "xx" }, onComplete ) -- Handler that gets notified when the alert closes end end
Can somebody explain to me - why?