Skip to content
Francisco Dias edited this page Jul 29, 2026 · 11 revisions

Banner

Functions for creating and managing banner ads - a small ad that stays anchored to the top or bottom of the screen.

Functions

This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.

Constants

This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.



Back To Top

admob_banner_set_ad_unit

Sets the ad unit ID used by admob_banner_create/admob_banner_create_ext. Must be called before either of those.


Syntax:

admob_banner_set_ad_unit(ad_unit_id)
Argument Type Description
ad_unit_id String The banner ad unit ID, from the AdMob dashboard.

Returns:

N/A



Back To Top

admob_banner_create

Creates and loads a banner ad, horizontally centered, anchored to the top or bottom of the screen. Only one banner exists at a time - calling this again replaces the previous banner.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.


Syntax:

admob_banner_create(size, bottom, callback)
Argument Type Description
size AdMobBannerSize The banner size to request.
bottom Boolean true to anchor the banner to the bottom of the screen, false for the top.
callback Function The function to call for every lifecycle event on this banner, for as
long as it exists.

Returns:

AdMobError

AdMobError.Ok if the create request was accepted, an error code otherwise.


Triggers:

Callback

Fires once per lifecycle event, for as long as this banner exists (not a one-shot load-then-show pair like the other ad families - a banner has one ongoing callback for its whole lifecycle).

Key Type Description
result AdMobResult The event's result. success is false only for
AdMobBannerCallbackEvent.LoadFailed.
type AdMobBannerCallbackEvent Which lifecycle event this is.

Example:

admob_banner_set_ad_unit("ca-app-pub-3940256099942544/6300978111");
admob_banner_create(AdMobBannerSize.Banner, true, function(_result, _type)
{
    if (_type == AdMobBannerCallbackEvent.LoadFailed)
        show_debug_message($"Banner failed to load: {_result.error_message}");
    else
        show_debug_message($"Banner event: {_type}");
});


Back To Top

admob_banner_create_ext

Same as admob_banner_create, with an explicit horizontal alignment instead of always centering.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.


Syntax:

admob_banner_create_ext(size, bottom, alignment, callback)
Argument Type Description
size AdMobBannerSize The banner size to request.
bottom Boolean true to anchor the banner to the bottom of the screen, false for the top.
alignment AdMobBannerAlignment The horizontal alignment for the banner.
callback Function The function to call for every lifecycle event on this banner, for as
long as it exists.

Returns:

AdMobError

AdMobError.Ok if the create request was accepted, an error code otherwise.


Triggers:

Callback

Fires once per lifecycle event, for as long as this banner exists. Same shape as admob_banner_create's callback.

Key Type Description
result AdMobResult The event's result. success is false only for
AdMobBannerCallbackEvent.LoadFailed.
type AdMobBannerCallbackEvent Which lifecycle event this is.


Back To Top

admob_banner_get_width

Gets the width, in pixels, of the current banner ad.


Syntax:

admob_banner_get_width()

Returns:

Real

The banner's width in pixels, or 0 if no banner exists.



Back To Top

admob_banner_get_height

Gets the height, in pixels, of the current banner ad.


Syntax:

admob_banner_get_height()

Returns:

Real

The banner's height in pixels, or 0 if no banner exists.



Back To Top

admob_banner_move

Moves the current banner ad to the opposite edge of the screen.


Syntax:

admob_banner_move(bottom)
Argument Type Description
bottom Boolean true to anchor the banner to the bottom of the screen, false for the top.

Returns:

N/A



Back To Top

admob_banner_show

Makes a previously-hidden banner ad visible again. Does nothing if no banner exists.


Syntax:

admob_banner_show()

Returns:

N/A



Back To Top

admob_banner_hide

Hides the current banner ad without destroying it - it keeps its loaded state and can be shown again with admob_banner_show. Does nothing if no banner exists.


Syntax:

admob_banner_hide()

Returns:

N/A



Back To Top

admob_banner_remove

Destroys the current banner ad entirely. Call admob_banner_create/ admob_banner_create_ext again to create a new one.


Syntax:

admob_banner_remove()

Returns:

N/A



Back To Top

AdMobBannerAlignment

Extension-defined horizontal banner placement values, used by admob_banner_create_ext.

These constants are referenced by the following functions:


Member Description
Left
Center
Right


Back To Top

AdMobBannerSize

Extension-defined numeric mapping to Google's banner-size APIs.

These constants are referenced by the following functions:


Member Description
Banner A standard 320x50 banner.
LargeBanner A 320x100 banner.
MediumRectangle A 300x250 banner.
FullBanner A 468x60 banner.
Leaderboard A 728x90 banner.
SmartBanner A screen-width, auto-height banner. Deprecated by Google in favor of adaptive
banners - kept for backward compatibility.
AnchoredAdaptive A screen-width banner with a height Google optimizes for the current
device and orientation. The recommended choice for new integrations.


Back To Top

AdMobBannerCallbackEvent

The lifecycle events admob_banner_create/admob_banner_create_ext's callback can fire with. Numeric values are extension-owned.

These constants are referenced by the following functions:


Member Description
Loaded The banner finished loading and is ready to show.
LoadFailed The banner failed to load. AdMobResult.success is false for this
event only.
Opened The banner was clicked and an overlay was presented.
Clicked The user clicked the banner.
Closed The overlay presented after a click was closed.
Impression The banner recorded an impression.


Clone this wiki locally