Adcolony_Load()
Syntax: _Adcolony_Load(zoneName, Additional_Parameters)
Purpose: Preloads an AdColony video ad (interstitial or rewarded). This is essential; you can't display an ad instantly without loading it first.
Parameters:
zoneName (required): The name of the zone you defined during AdColony initialization.
Additional_Parameters (optional): Control behavior like pre/post popups for rewarded ads. Example: "prePopup=true"
Adcolony_Show()
Syntax: _Adcolony_Show(zoneName)
Purpose: Displays a preloaded AdColony ad.
Parameters:
zoneName (required): The zone name to display.
Important:
Use Adcolony_is_Loaded()
to check if an ad is ready before trying to show it.
Adcolony_is_Loaded()
Syntax: _Adcolony_is_Loaded(zoneName)
Purpose: Checks if an ad for a specific zone has finished loading.
Parameters:
zoneName (required): The zone to check.
Returns:
true
if the ad is loaded, false
otherwise.
Example Workflow
Lua
-- Load an interstitial ad for "zone1"
Adcolony_Load(
"zone1"
)
-- ... later in your game logic ...
if
Adcolony_is_Loaded(
"zone1"
)
then
Adcolony_Show(
"zone1"
)
end
Let's Explore!
Rewarded Ads: Want to investigate how to differentiate between interstitial and rewarded ads and implement those?
Troubleshooting: Anticipate common error scenarios (ad not loading, etc.) and how to debug them?
Admob_Height()
Syntax: _Admob_Height()
Purpose: Specifically for banner ads. It retrieves the height (in content coordinates) of a preloaded banner ad. This helps with precise positioning before showing it.
Important:
You
must have preloaded a banner ad using Admob_Load("banner")
for this function to return a meaningful value.
If
the device is rotated, you'll often need to reload the banner ad
and call Admob_Height()
again for accurate positioning.
Admob_Hide()
Syntax: _Admob_Hide()
Purpose:
Also banner
ad specific.
Removes any currently displayed banner ad and prevents automatic
retrieval of new ones until you call Admob_Show("banner")
again.
Let's See it in Action!
Hypothetical Scenario: You have a game with an optional button to "Hide Ads".
Lua
-- Function called when the user presses the "Hide Ads" button
function
onHideAdsPressed
()
Admob_Hide()
end
Considerations
Ad Revenue: Hiding ads likely means a loss of ad revenue.
User Experience: Offer this as an option or a reward if it fits with your game's design.
What would you like to focus on next?
Essential
Setup:
Do you want to go through the Admob initialization process (the
Admob_Init()
or Admob_Implementation()
functions)?
Loading
an Ad:
Would you like to practice with the Admob_Load()
command and its parameters?
Admob_Implementation()
Syntax: _Admob_Implementation(app_Key,test_Mode,ad_Id_banner,banner_position,ad_Id_interstitial,ad_Id_rewarded,childSafe,huawei)
Purpose:
An older way of initializing the Admob system in Lu C Studio. The
newer Admob_Init()
is the recommended approach.
Parameters:
app_Key (required): Your Admob App Key (separate IDs for Android/iOS, comma-separated).
test_Mode
(required):
true
to enable test ads, false
for live ads.
ad_Id_banner (optional): Ad unit ID for banner ads.
banner_position (optional): "top" or "bottom" (default).
ad_Id_interstitial (optional): Ad unit ID for interstitial ads.
ad_Id_rewarded (optional): Ad unit ID for rewarded ads.
childSafe
(optional):
true
for COPPA-compliant ads, false
otherwise (default).
huawei
(optional):
true
to use Huawei ads, false
for standard Admob (default).
Admob_Init()
Syntax: _Admob_Init(app_Key,Additional_Parameters,Init_Completed,Ad_Loaded,Ad_Closed,Ad_Completed,Ad_Clicked,Ad_Failed,huawei)
Purpose: The preferred way to initialize Admob in your Lu C projects.
Parameters:
app_Key (required): Your Admob App Key (separate IDs for Android/iOS, comma-separated).
Additional_Parameters (optional): Control things like test mode, video ad volume, etc.
Init_Completed, Ad_Loaded, ... (optional): Callback functions for various events during the ad process.
huawei
(optional):
true
to use Huawei ads, false
for standard Admob (default).
Important:
You
must
call either Admob_Init()
or Admob_Implementation()
before using other Admob functions.
Callback functions allow you to react to events like an ad being loaded or closed by the user.
Example (Basic Initialization)
Lua
Admob_Init(
"YOUR_ADMOB_APP_KEY"
,
"testMode=true"
)
Let's Practice
Would you like to:
Test Mode: Experiment with enabling/disabling test ads within initialization?
Event Handling: Write some simple callback functions (e.g., print a message when an ad loads)?
Admob_Interstitial()
Syntax: _Admob_Interstitial(function_to_execute_after_interstitial)
Purpose: Displays an interstitial ad (fullscreen, between game levels, etc.). Crucially, this function also requires a callback function.
Parameters:
function_to_execute_after_interstitial (required): This function will be executed either after the interstitial ad is closed or if no interstitial ad is available.
Why the Callback? Since interstitial ads often disrupt gameplay, you need to know when they're finished so you can resume your game logic.
Example:
Lua
function
resumeGameAfterAd
()
-- Restart the game level, etc.
end
Admob_Interstitial(resumeGame afterAd)
Admob_Load()
Syntax: _Admob_Load(adType, Additional_Parameters)
Purpose:
Preloads an Admob ad (interstitial
,
banner
,
or rewardedVideo
).
Remember:
You can't show an ad until it's loaded.
Parameters:
adType (required): One of:
"interstitial"
"banner"
"rewardedVideo"
Additional_Parameters (optional): Things like Ad Unit IDs, child safety settings, keywords for targeting, etc.
Example:
Lua
Admob_Load(
"interstitial"
,
"adUnitId=YOUR_INTERSTITIAL_AD_UNIT_ID, childSafe=true"
)
Admob_Rewarded()
Syntax: _Admob_Rewarded(function_to_execute_if_not_available, function_to_execute_after_rewarded, function_to_execute_after_rewarded_fail)
Purpose: Implements rewarded video ads, where the player optionally watches an ad in exchange for in-game rewards.
Parameters:
function_to_execute_if_not_available (required): Executes if no rewarded ad is ready.
function_to_execute_after_rewarded (required): Executes if the player watches the entire ad. This is where you'd give in-game rewards.
function_to_execute_after_rewarded_fail (required): Executes if the player doesn't complete the ad (closes early, etc.)
Example (Conceptual):
Lua
function
onNoRewardedAd
()
(
"No rewarded ad available at the moment."
)
end
function
onRewardedAdSuccess
()
givePlayerExtraCoins()
end
function
onRewardedAdFailed
()
(
"Sorry, you didn't watch the entire ad."
)
end
Admob_Rewarded(onNoRewardedAd, onRewardedAdSuccess, onRewardedAdFailed)
Admob_Set_Video_Ad_Volume()
Syntax: _Admob_Set_Video_Ad_Volume(videoAdVolume)
Purpose: Controls the audio volume specifically for video-based ads (interstitial, rewarded).
Parameters:
videoAdVolume (required): A number between 0.0 (mute) and 1.0 (full volume).
Admob_Show()
Syntax: _Admob_Show(adType, Additional_Parameters)
Purpose: Displays a preloaded Admob ad.
Parameters:
adType (required): One of "interstitial", "banner", or "rewardedVideo"
Additional_Parameters
(optional, banner ads only):
Controls banner position (y=
)
and background color (bgColor
=
)
Important:
Use
Admob_is_Loaded()
to check if an ad is ready before calling Admob_Show()
.
Let's Experiment!
Would you like to:
Banner
Ad Placement:
Practice displaying banner ads at the top or bottom of the screen
using the y=
parameter in Admob_Show()
?
Volume
Control:
Test out different volume levels for video ads using
Admob_Set_Video_Ad_Volume()
?
Admob_is_Loaded()
Syntax: _Admob_is_Loaded(ad_type)
Purpose: Checks whether a specific ad type has been pre-loaded and is ready to be shown. Essential to avoid errors when attempting to display ads.
Parameters:
adType (required): One of: "interstitial", "banner", or "rewardedVideo"
Returns:
true
if the ad is loaded, false
otherwise.
Example:
Lua
if
Admob_is_Loaded(
"interstitial"
)
then
Admob_Show(
"interstitial"
)
end
Ads_Removed()
Syntax: _Ads_Removed()
Purpose: A generic, not ad-network specific, function to check if the user has potentially purchased an "ad removal" option within your game or app.
Returns:
true
if ads might be disabled, false
otherwise.
Important: You would need to implement your own system for in-app purchases or subscriptions to handle ad removal, and integrate that logic with this function's result.
Putting it All Together: A Common Ad Workflow
Initialization:
Call Admob_Init()
.
Preloading:
Use Admob_Load()
to prepare an ad of the desired type (interstitial
,
banner
,
or rewardedVideo
).
Check
Readiness:
Before attempting to show an ad, use Admob_is_Loaded()
.
Display:
Call Admob_Show()
if the ad is loaded.
Callbacks
(Optional):
Provide functions to Admob_Init()
,
Admob_Interstitial()
,
and Admob_Rewarded()
to react to events (ad closed, reward granted, etc.).
Privacy_Policy()
Purpose: This function is intended to display your app's privacy policy to the user.
Set_Remove_Ads()
Purpose: Controls a hypothetical "remove ads" state in your app. Likely tied into your own in-app purchase or subscription logic.
Parameters:
ad_state:
true
:
Assumes ads should be disabled.
false
:
Assumes ads should be shown.
default_ad_banner_height_(), default_ad_banner_skip_curvature_()
Purpose: Seem to be very specialized functions for customizing the appearance of banner ads.
Parameters:
default_ad_banner_height_(): Likely controls the default height of banner ads.
default_ad_banner_skip_curvature_(): This might relate to how banner ads adjust to rounded screen corners on modern devices.
Caution:
These functions might be specific to a particular ad network plugin.
Their exact behavior could depend on the ad provider you are using.