The library in development stage. May be not fully tested and README may be not full. If you have any questions, please, create an issue. This library is an adoptation of Token module from my Defold-Eva library.
Token - library designed for the Defold game engine to manage countable items such as money, lives, and other numeric values. This library provides a robust and flexible system for handling various token-related operations, including creation, management, and restoration of token values.
- Token Management - Create, delete, and manage tokens within containers.
- Container Management - Create, delete, and manage token containers.
- Callbacks - Customizable callbacks for token changes.
- Token Groups - Support for grouped token operations.
- Token Restoration - Configurable restoration mechanics for tokens.
- Infinity Tokens - Manage tokens with infinite time usage.
Open your game.project
file and add the following line to the dependencies field under the project section:
https://github.com/Insality/defold-event/archive/refs/tags/11.zip
https://github.com/Insality/defold-token/archive/refs/tags/1.zip
After that, select Project ▸ Fetch Libraries
to update library dependencies. This happens automatically whenever you open a project so you will only need to do this if the dependencies change without re-opening the project.
Note: The library size is calculated based on the build report per platform
Platform | Library Size |
---|---|
HTML5 | 4.68 KB |
Desktop / Mobile | 9.01 KB |
- Token: A countable item such as money, lives, or other numeric values.
- Container: A collection of tokens.
- Token Group: A group of tokens that can be managed together and have a group id.
- Token Lot: A data with a price group id and reward group id. Can be used for shop items, for example.
token.init([config_or_path])
token.reset_state()
-- Events
token.on_token_change -- (container_id, token_id, amount, reason)
token.on_token_visual_change -- (container_id, token_id, amount)
token.on_token_restore_change -- (container_id, token_id, restore_config)
token.create_container(container_id)
token.delete_container(container_id)
token.clear_container(container_id)
token.is_container_exist(container_id)
token.get(container_id, token_id)
token.set(container_id, token_id, amount, reason)
token.add(container_id, token_id, amount, reason, visual_later)
token.pay(container_id, token_id, amount, reason, visual_later)
token.is_enough(container_id, token_id, amount)
token.get_many(container_id)
token.set_many(container_id, tokens, reason, visual_later)
token.add_many(container_id, tokens, reason, visual_later)
token.pay_many(container_id, tokens, reason, visual_later)
token.is_enough_many(container_id, tokens)
token.get_token_group(token_group_id)
token.add_group(container_id, token_group_id, reason, visual_later)
token.set_group(container_id, token_group_id, reason, visual_later)
token.pay_group(container_id, token_group_id, reason, visual_later)
token.is_enough_group(container_id, token_group_id)
token.create_restore_config()
token.set_restore_config(container_id, token_id, config)
token.get_restore_config(container_id, token_id)
token.set_restore_enabled(container_id, token_id, is_enabled)
token.is_restore_enabled(container_id, token_id)
token.remove_restore_config(container_id, token_id)
token.get_time_to_restore(container_id, token_id)
token.get_lot_reward(lot_id)
token.get_lot_price(lot_id)
token.add_infinity_time(container_id, token_id, seconds)
token.get_infinity_time(container_id, token_id)
token.set_infinity_time(container_id, token_id, seconds)
token.is_infinity_time(container_id, token_id)
token.get_visual(container_id, token_id)
token.add_visual(container_id, token_id, amount)
token.sync_visual(container_id, token_id)
token.get_total_sum(container_id, token_id)
token.set_logger([logger_instance])
Read the API Reference file to see the full API documentation for the module.
Read the Use Cases file to see several examples of how to use the this module in your Defold game development projects.
This project is licensed under the MIT License - see the LICENSE file for details.
For any issues, questions, or suggestions, please create an issue.
Your donation helps me stay engaged in creating valuable projects for Defold. If you appreciate what I'm doing, please consider supporting me!