Skip to content

Commit

Permalink
Merge pull request #5 from alexeyfeskov/autocomplete-api
Browse files Browse the repository at this point in the history
Add Defold Editor autocomplete-api (#4)
  • Loading branch information
alexeyfeskov authored Apr 3, 2021
2 parents 0e57267 + 80d6195 commit 56c9ea0
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 101 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
*.render_script linguist-language=Lua
*.script linguist-language=Lua
*.gui_script linguist-language=Lua

# Defold YAML Files
*.script_api=YAML
201 changes: 101 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ or point to the ZIP file of a [specific release](https://github.com/alexeyfeskov

## Example

See the [example folder](https://github.com/alexeyfeskov/defold-maxsdk/tree/master/example) for understand how to use extension. Especially [ui.gui_script](https://github.com/alexeyfeskov/defold-maxsdk/blob/master//example/ads.gui_script) file.
See the [example folder](https://github.com/alexeyfeskov/defold-maxsdk/tree/master/example) for understand how to use extension. Especially [ads.gui_script](https://github.com/alexeyfeskov/defold-maxsdk/blob/master/example/ads.gui_script) file.

## LUA Api

Expand All @@ -30,123 +30,124 @@ Please, read original [Android API docs](https://dash.applovin.com/documentation
-- Initialize SDK and start load ads --
---------------------------------------
if maxsdk then
-- To enable LDU with geolocation https://developers.facebook.com/docs/audience-network/guides/ccpa
maxsdk.set_fb_data_processing_options("LDU", 0, 0)
maxsdk.set_has_user_consent(true) -- GDPR
maxsdk.set_is_age_restricted_user(false)
maxsdk.set_do_not_sell(false) -- CCPA for all others mediated networks

maxsdk.set_muted(false)
maxsdk.set_verbose_logging(true)

maxsdk.set_callback(maxsdk_callback)
maxsdk.initialize()

-- all `load_***` functions can recieve last optional `string` arg to define placement_id
maxsdk.load_interstitial(interstitial_ad_unit)
maxsdk.load_rewarded(rewarded_ad_unit)
maxsdk.load_banner(banner_ad_unit, maxsdk.SIZE_BANNER)
-- Supported banner sizes:
-- maxsdk.SIZE_BANNER
-- maxsdk.SIZE_LEADER
-- maxsdk.SIZE_MREC (use separate ad_unit, all other APIs are same to banners)
-- To enable LDU with geolocation https://developers.facebook.com/docs/audience-network/guides/ccpa
maxsdk.set_fb_data_processing_options("LDU", 0, 0)
maxsdk.set_has_user_consent(true) -- GDPR
maxsdk.set_is_age_restricted_user(false)
maxsdk.set_do_not_sell(false) -- CCPA for all others mediated networks

maxsdk.set_muted(false)
maxsdk.set_verbose_logging(true)

maxsdk.set_callback(maxsdk_callback)
maxsdk.initialize()

maxsdk.load_interstitial(interstitial_ad_unit)
maxsdk.load_rewarded(rewarded_ad_unit)
maxsdk.load_banner(banner_ad_unit, maxsdk.SIZE_BANNER)
-- Supported banner sizes:
-- maxsdk.SIZE_BANNER
-- maxsdk.SIZE_LEADER
-- maxsdk.SIZE_MREC (use separate ad_unit, all other APIs are same to banners)
end

--------------
-- Show ads --
--------------
-- all `show_***` functions have optional `string` parameter to define placement
if maxsdk and maxsdk.is_interstitial_loaded() then
maxsdk.show_interstitial()
maxsdk.show_interstitial()
end

if maxsdk and maxsdk.is_rewarded_loaded() then
maxsdk.show_rewarded()
maxsdk.show_rewarded()
end

if maxsdk and maxsdk.is_banner_loaded() then
maxsdk.show_banner(maxsdk.POS_TOP_CENTER)
-- Supported banner positions:
-- maxsdk.POS_BOTTOM_CENTER
-- maxsdk.POS_BOTTOM_LEFT
-- maxsdk.POS_BOTTOM_RIGHT
-- maxsdk.POS_NONE
-- maxsdk.POS_TOP_LEFT
-- maxsdk.POS_TOP_CENTER
-- maxsdk.POS_TOP_RIGHT
-- maxsdk.POS_CENTER

-- Also you can: temporary hide banner
maxsdk.hide_banner()
-- ..show in other position
maxsdk.show_banner(maxsdk.POS_BOTTOM_CENTER)
-- ..or unload
maxsdk.destroy_banner()
maxsdk.show_banner(maxsdk.POS_TOP_CENTER)
-- Supported banner positions:
-- maxsdk.POS_BOTTOM_CENTER
-- maxsdk.POS_BOTTOM_LEFT
-- maxsdk.POS_BOTTOM_RIGHT
-- maxsdk.POS_NONE
-- maxsdk.POS_TOP_LEFT
-- maxsdk.POS_TOP_CENTER
-- maxsdk.POS_TOP_RIGHT
-- maxsdk.POS_CENTER

-- Also you can: temporary hide banner
maxsdk.hide_banner()
-- ..show in other position
maxsdk.show_banner(maxsdk.POS_BOTTOM_CENTER)
-- ..or unload
maxsdk.destroy_banner()
end

------------------------
-- Receive SDK events --
------------------------
function maxsdk_callback(self, message_id, message)
if message_id == maxsdk.MSG_INITIALIZATION then
print("MSG_INITIALIZATION")

elseif message_id == maxsdk.MSG_INTERSTITIAL then
if message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Interstitial AD closed")
elseif message.event == maxsdk.EVENT_CLICKED then
print("EVENT_CLICKED: Interstitial AD clicked")
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Interstitial AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Interstitial AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Interstitial AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Interstitial AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_interstitial() before EVENT_LOADED", message.code, message.error)
end

elseif message_id == maxsdk.MSG_REWARDED then
if message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Rewarded AD closed")
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Rewarded AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Rewarded AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Rewarded AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Rewarded AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_rewarded() before EVENT_LOADED", message.code, message.error)
elseif message.event == maxsdk.EVENT_EARNED_REWARD then
print("EVENT_EARNED_REWARD: Reward: ", message.amount, message.type)
end

elseif message_id == maxsdk.MSG_BANNER then
if message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Banner AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Banner AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Banner AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Banner AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_EXPANDED then
print("EVENT_EXPANDED: Banner AD expanded")
elseif message.event == maxsdk.EVENT_COLLAPSED then
print("EVENT_COLLAPSED: Banner AD coppalsed")
elseif message.event == maxsdk.EVENT_CLICKED then
print("EVENT_CLICKED: Banner AD clicked")
elseif message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Banner AD closed")
elseif message.event == maxsdk.EVENT_DESTROYED then
print("EVENT_DESTROYED: Banner AD destroyed")
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_banner() before EVENT_LOADED", message.code, message.error)
end
end
if message_id == maxsdk.MSG_INITIALIZATION then
print("MSG_INITIALIZATION")

elseif message_id == maxsdk.MSG_INTERSTITIAL then
if message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Interstitial AD closed")
elseif message.event == maxsdk.EVENT_CLICKED then
print("EVENT_CLICKED: Interstitial AD clicked")
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Interstitial AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Interstitial AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Interstitial AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Interstitial AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_interstitial() before EVENT_LOADED", message.code, message.error)
end

elseif message_id == maxsdk.MSG_REWARDED then
if message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Rewarded AD closed")
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Rewarded AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Rewarded AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Rewarded AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Rewarded AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_rewarded() before EVENT_LOADED", message.code, message.error)
elseif message.event == maxsdk.EVENT_EARNED_REWARD then
print("EVENT_EARNED_REWARD: Reward: ", message.amount, message.type)
end

elseif message_id == maxsdk.MSG_BANNER then
if message.event == maxsdk.EVENT_LOADED then
print("EVENT_LOADED: Banner AD loaded. Network:", message.network)
elseif message.event == maxsdk.EVENT_OPENING then
print("EVENT_OPENING: Banner AD is opening")
elseif message.event == maxsdk.EVENT_FAILED_TO_LOAD then
print("EVENT_FAILED_TO_LOAD: Banner AD failed to load", message.code, message.error)
elseif message.event == maxsdk.EVENT_FAILED_TO_SHOW then
print("EVENT_FAILED_TO_SHOW: Banner AD failed to show", message.code, message.error)
elseif message.event == maxsdk.EVENT_EXPANDED then
print("EVENT_EXPANDED: Banner AD expanded")
elseif message.event == maxsdk.EVENT_COLLAPSED then
print("EVENT_COLLAPSED: Banner AD coppalsed")
elseif message.event == maxsdk.EVENT_CLICKED then
print("EVENT_CLICKED: Banner AD clicked")
elseif message.event == maxsdk.EVENT_CLOSED then
print("EVENT_CLOSED: Banner AD closed")
elseif message.event == maxsdk.EVENT_DESTROYED then
print("EVENT_DESTROYED: Banner AD destroyed")
elseif message.event == maxsdk.EVENT_NOT_LOADED then
print("EVENT_NOT_LOADED: can't call show_banner() before EVENT_LOADED", message.code, message.error)
end
end
end
```

Feel free to push a Pull Request with other features implementation.
2 changes: 1 addition & 1 deletion example/ads.gui_script
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local dirtylarry = require "dirtylarry/dirtylarry"

local MAX_LOG_LINES = 37
local MAX_LOG_LINES = 36

--log logic
local gprint = print
Expand Down
Loading

0 comments on commit 56c9ea0

Please sign in to comment.