Skip to Content
defold-typescript libraries
megalanthusdefold-gamepush

megalanthus/defold-gamepush/gamepush.core.rewards

GamePush rewards: giving, accepting and checking rewards, with their events.

  • GitHub: megalanthus/defold-gamepush — pinned to v1.4.1
    1. Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as core_rewards from "gamepush.core.rewards"

Functions

give(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Gives the player a reward. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The reward, for example { id: 18 }.
  • callback?: (result: unknown) => void — Receives the result.

accept(parameters: Record<string, unknown>, callback?: (result: unknown) => void)

Accepts a reward the player was given. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The reward, for example { id: "my_reward" }.
  • callback?: (result: unknown) => void — Receives the result.

list(): Record<string, unknown>[]

All rewards.

Returns

  • Record<string, unknown>[]

given_list(): Record<string, unknown>[]

The rewards the player was given.

Returns

  • Record<string, unknown>[]

get_reward(id_or_tag: string | number): Record<string, unknown>

A reward's description.

Parameters

  • id_or_tag: string | number — The reward's id or tag.

Returns

  • Record<string, unknown>

has(id_or_tag: string | number): boolean

Whether the player was given a reward.

Parameters

  • id_or_tag: string | number — The reward's id or tag.

Returns

  • boolean

has_accepted(id_or_tag: string | number): boolean

Whether the player accepted a reward.

Parameters

  • id_or_tag: string | number — The reward's id or tag.

Returns

  • boolean

has_unaccepted(id_or_tag: string | number): boolean

Whether the player was given a reward but has not accepted it.

Parameters

  • id_or_tag: string | number — The reward's id or tag.

Returns

  • boolean

Variables

callbacks: RewardsCallbacks

The reward event handlers.

Types

RewardsCallbacks

RewardsCallbacks.give?: (reward: unknown) => void

A reward was given.

RewardsCallbacks.error_give?: (error: unknown) => void

Giving a reward failed.

RewardsCallbacks.accept?: (reward: unknown) => void

A reward was accepted.

RewardsCallbacks.error_accept?: (error: unknown) => void

Accepting a reward failed.

On this page