Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Nov 23, 2023
1 parent d07e2bd commit f318441
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: defold
patreon: Defold
custom: ['https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NBNBHTUW4GS4C']
19 changes: 19 additions & 0 deletions .github/workflows/trigger-site-rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Trigger site rebuild

on: [push]

jobs:
site-rebuild:
runs-on: ubuntu-latest

steps: [
{
name: 'Repository dispatch',
uses: defold/[email protected],
with: {
repo: 'defold/defold.github.io',
token: '${{ secrets.SERVICES_GITHUB_TOKEN }}',
user: '[email protected]',
action: 'extension-poki-sdk'
}
}]
39 changes: 3 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
# Poki SDK native extension for Defold game engine
![pokisdk-hero](https://user-images.githubusercontent.com/2209596/102117637-db1df480-3e3e-11eb-9822-db237f36c0f6.jpg)
## Installation
To use this library in your Defold project, add the needed version URL to your `game.project` dependencies from [Releases](https://github.com/AGulev/defold-poki-sdk/releases)
# Poki SDK Extension for Defold

<img width="401" alt="image" src="https://user-images.githubusercontent.com/2209596/202223571-c77f0304-5202-4314-869d-7a90bbeec5ec.png">
Defold [native extension](https://www.defold.com/manuals/extensions/) which provides access to the Poki SDK.


## API

Lua API corresponds to original JS API SDK:

```lua
poki_sdk.gameplay_start() -- in JS it's PokiSDK.gameplayStart()
poki_sdk.gameplay_stop() -- in JS it's PokiSDK.gameplayStop()
poki_sdk.commercial_break(function(self)end) -- in JS it's PokiSDK.commercialBreak()
poki_sdk.rewarded_break(function(self, success)end) -- in JS it's PokiSDK.rewardedBreak()
poki_sdk.set_debug(value) -- in JS it's PokiSDK.setDebug(value)
poki_sdk.capture_error(error_string) -- in JS it's PokiSDK.captureError(error_string)
poki_sdk.shareable_url(params, callback) -- in JS it's PokiSDK.shareableURL({}).then(url => {})
local value = poki_sdk.get_url_param(key) -- in JS it's PokiSDK.getURLParam('id')

-- Also, it's possible to check if AdBlock is active.
poki_sdk.is_ad_blocked()
```
Use this instruction: [PokiSDK - Defold](https://sdk.poki.com/defold.html)

Do not collect Lua errors manually using `sys.set_error_handler()`. The SDK collects Lua errors and the engine's errors and warnings automatically.

When you get your PokiSDK Sitelock code, just add it to your game as:
```lua
html5.run("Sitelock JS code from Poki")
```
For security reasons, this piece of code is not public, so please request it from your Poki contact.

---

If you have any issues, questions or suggestions please [create an issue](https://github.com/AGulev/defold-poki-sdk/issues) or contact me: [email protected]
[Manual, API and setup instructions](https://www.defold.com/extension-poki-sdk/) is available on the official Defold site.
Binary file added docs/add-dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 126 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: Defold Poki SDK extension API documentation
brief: This manual covers how to use AdMob to show ads on iOS and Android in Defold.
---

# Defold Poki SDK extension API documentation

This extension provides a Poki SDK integration for Defold.


# Installation
To use Poki SDK in your Defold project, add a version of the Poki SDK extension to your `game.project` dependencies from the list of available [Releases](https://github.com/defold/extension-poki-sdk/releases). Find the version you want, copy the URL to ZIP archive of the release and add it to the project dependencies.

![](add-dependency.png)

Select `Project->Fetch Libraries` once you have added the version to `game.project` to download the version and make it available in your project.

# Usage


## Implement the gameplay events

Use the `poki_sdk.gameplay_start()` event to describe when users are playing your game (e.g. level start and unpause).

Use the `poki_sdk.gameplay_stop()` event to describe when users aren’t playing your game (e.g. level finish, game over, pause, quit to menu).

```lua
-- first level loads, player clicks anywhere
poki_sdk.gameplay_start()
-- player is playing
-- player loses round
poki_sdk.gameplay_stop()
-- game over screen pops up
```


## Implement commercial breaks

Commercial breaks are used to display video ads and should be triggered on natural breaks in your game. Throughout the rest of your game, we recommend you implement the `poki_sdk.commercial_break()` before every `poki_sdk.gameplay_start()`, i.e. whenever the user has shown an intent to continue playing.

```lua
-- gameplay stops
poki_sdk.commercial_break(function(self)end)
```

### Important information about commercial breaks

Not every single `poki_sdk.commercial_break()` will trigger an ad. Poki’s system will determine when a user is ready for another ad, so feel free to signal as many commercial break opportunities as possible.


## Implement rewarded breaks
Rewarded breaks allow for a user to choose to watch a rewarded video ad in exchange for a certain benefit in the game (e.g. more coins, etc.). When using `poki_sdk.rewarded_break()`, please make it clear to the player beforehand that they’re about to watch an ad.

```lua
-- gameplay stops
poki_sdk.rewarded_break(function(self, success)end)
```

### About the rewarded break timer

Calling `poki_sdk.rewarded_break()` affects the timing of `poki_sdk.commercial_break()` - When a user interacts with a rewarded break, our system’s ad timer is reset to ensure the user does not immediately see another ad.


## Final steps

### Disable sound and input during ads

Make sure that audio and keyboard input are disabled during commercialBreaks, so that the game doesn’t interfere with the ad:

```lua
-- gameplay stops
-- fire your mute audio function
poki_sdk.commercial_break(function(self)
-- fire your unmute audio function
-- fire your function to continue to game
end)
```

### Upload and test your game in Poki for Developers

Congrats, you’ve successfully implemented the PokiSDK! Now upload your game to the Poki Inspector and test it there. When you’re happy with the implementation, send Poki a review request and they'll play the game. Feel free to contact Poki via Discord or [email protected] if you’re stuck.


## Error handling

Do not collect Lua errors manually using `sys.set_error_handler()`. The SDK collects Lua errors and the engine's errors and warnings automatically.


## Adding Sitelock
When you get your PokiSDK Sitelock code, just add it to your game as:
```lua
html5.run("Sitelock JS code from Poki")
```
For security reasons, this piece of code is not public, so please request it from your Poki contact.


## Example

[Refer to the example project](https://github.com/defold/extension-poki-sdk/blob/master/main/poki-sdk.gui_script) to see a complete exameple of how the intergation works.


## Source code

The source code is available on [GitHub](https://github.com/defold/extension-poki-sdk)


## API

The Poki SDK Lua API corresponds to original JS API SDK:

```lua
poki_sdk.gameplay_start() -- in JS it's PokiSDK.gameplayStart()
poki_sdk.gameplay_stop() -- in JS it's PokiSDK.gameplayStop()
poki_sdk.commercial_break(function(self)end) -- in JS it's PokiSDK.commercialBreak()
poki_sdk.rewarded_break(function(self, success)end) -- in JS it's PokiSDK.rewardedBreak()
poki_sdk.set_debug(value) -- in JS it's PokiSDK.setDebug(value)
poki_sdk.capture_error(error_string) -- in JS it's PokiSDK.captureError(error_string)
poki_sdk.shareable_url(params, callback) -- in JS it's PokiSDK.shareableURL({}).then(url => {})
local value = poki_sdk.get_url_param(key) -- in JS it's PokiSDK.getURLParam('id')

-- Also, it's possible to check if AdBlock is active.
poki_sdk.is_ad_blocked()
```


## API reference

0 comments on commit f318441

Please sign in to comment.