{"id":16085191,"url":"https://github.com/Insality/defold-token","last_synced_at":"2025-10-23T01:31:46.902Z","repository":{"id":251496609,"uuid":"837576800","full_name":"Insality/defold-token","owner":"Insality","description":"Defold Countable Items Container","archived":false,"fork":false,"pushed_at":"2024-08-03T11:46:53.000Z","size":618,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T08:45:29.433Z","etag":null,"topics":["defold","defold-extension","defold-library","defold-module","token"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Insality.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"insality","ko_fi":"insality","buy_me_a_coffee":"insality"}},"created_at":"2024-08-03T11:40:35.000Z","updated_at":"2025-01-30T11:06:54.000Z","dependencies_parsed_at":"2024-08-03T13:55:44.978Z","dependency_job_id":"3cb56d21-9220-454d-bda7-82ffda2f0a1a","html_url":"https://github.com/Insality/defold-token","commit_stats":null,"previous_names":["insality/defold-token"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Insality","download_url":"https://codeload.github.com/Insality/defold-token/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237763855,"owners_count":19362310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defold","defold-extension","defold-library","defold-module","token"],"created_at":"2024-10-09T13:01:52.196Z","updated_at":"2025-10-23T01:31:46.897Z","avatar_url":"https://github.com/Insality.png","language":"Lua","funding_links":["https://github.com/sponsors/insality","https://ko-fi.com/insality","https://buymeacoffee.com/insality","https://www.buymeacoffee.com/insality"],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"\n![](media/logo.png)\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/tag/insality/defold-token?style=for-the-badge\u0026label=Release)](https://github.com/Insality/defold-token/tags)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/insality/defold-token/ci-workflow.yml?branch=master\u0026style=for-the-badge)](https://github.com/Insality/defold-token/actions)\n[![codecov](https://img.shields.io/codecov/c/github/Insality/defold-token?style=for-the-badge)](https://codecov.io/gh/Insality/defold-token)\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n\n\n# Disclaimer\n\nThe 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](https://github.com/Insality/defold-eva/blob/master/eva/modules/token.lua) module from my [Defold-Eva](https://github.com/Insality/defold-eva) library.\n\n\n# Token\n\n**Token** - library designed for the [Defold](https://defold.com/) 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.\n\n\n## Features\n\n- **Token Management** - Create, delete, and manage tokens within containers.\n- **Container Management** - Create, delete, and manage token containers.\n- **Callbacks** - Customizable callbacks for token changes.\n- **Token Groups** - Support for grouped token operations.\n- **Token Restoration** - Configurable restoration mechanics for tokens.\n- **Infinity Tokens** - Manage tokens with infinite time usage.\n\n\n## Setup\n\n### [Dependency](https://www.defold.com/manuals/libraries/)\n\nOpen your `game.project` file and add the following line to the dependencies field under the project section:\n\n**[Defold Event](https://github.com/Insality/defold-event)**\n\n```\nhttps://github.com/Insality/defold-event/archive/refs/tags/11.zip\n```\n\n**[Defold Token](https://github.com/Insality/defold-token/archive/refs/tags/1.zip)**\n\n```\nhttps://github.com/Insality/defold-token/archive/refs/tags/1.zip\n```\n\nAfter that, select `Project ▸ Fetch Libraries` to update [library dependencies]((https://defold.com/manuals/libraries/#setting-up-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.\n\n### Library Size\n\n\u003e **Note:** The library size is calculated based on the build report per platform\n\n| Platform         | Library Size |\n| ---------------- | ------------ |\n| HTML5            | **4.68 KB**  |\n| Desktop / Mobile | **9.01 KB**  |\n\n\n### Glossary\n\n- **Token**: A countable item such as money, lives, or other numeric values.\n- **Container**: A collection of tokens.\n- **Token Group**: A group of tokens that can be managed together and have a group id.\n- **Token Lot**: A data with a price group id and reward group id. Can be used for shop items, for example.\n\n\n## API Reference\n\n### Quick API Reference\n\n```lua\ntoken.init([config_or_path])\ntoken.reset_state()\n\n-- Events\ntoken.on_token_change -- (container_id, token_id, amount, reason)\ntoken.on_token_visual_change -- (container_id, token_id, amount)\ntoken.on_token_restore_change -- (container_id, token_id, restore_config)\n\ntoken.create_container(container_id)\ntoken.delete_container(container_id)\ntoken.clear_container(container_id)\ntoken.is_container_exist(container_id)\n\ntoken.get(container_id, token_id)\ntoken.set(container_id, token_id, amount, reason)\ntoken.add(container_id, token_id, amount, reason, visual_later)\ntoken.pay(container_id, token_id, amount, reason, visual_later)\ntoken.is_enough(container_id, token_id, amount)\n\ntoken.get_many(container_id)\ntoken.set_many(container_id, tokens, reason, visual_later)\ntoken.add_many(container_id, tokens, reason, visual_later)\ntoken.pay_many(container_id, tokens, reason, visual_later)\ntoken.is_enough_many(container_id, tokens)\n\ntoken.get_token_group(token_group_id)\ntoken.add_group(container_id, token_group_id, reason, visual_later)\ntoken.set_group(container_id, token_group_id, reason, visual_later)\ntoken.pay_group(container_id, token_group_id, reason, visual_later)\ntoken.is_enough_group(container_id, token_group_id)\n\ntoken.create_restore_config()\ntoken.set_restore_config(container_id, token_id, config)\ntoken.get_restore_config(container_id, token_id)\ntoken.set_restore_enabled(container_id, token_id, is_enabled)\ntoken.is_restore_enabled(container_id, token_id)\ntoken.remove_restore_config(container_id, token_id)\ntoken.get_time_to_restore(container_id, token_id)\n\ntoken.get_lot_reward(lot_id)\ntoken.get_lot_price(lot_id)\n\ntoken.add_infinity_time(container_id, token_id, seconds)\ntoken.get_infinity_time(container_id, token_id)\ntoken.set_infinity_time(container_id, token_id, seconds)\ntoken.is_infinity_time(container_id, token_id)\n\ntoken.get_visual(container_id, token_id)\ntoken.add_visual(container_id, token_id, amount)\ntoken.sync_visual(container_id, token_id)\n\ntoken.get_total_sum(container_id, token_id)\n\ntoken.set_logger([logger_instance])\n```\n\n### API Reference\n\nRead the [API Reference](API_REFERENCE.md) file to see the full API documentation for the module.\n\n\n## Use Cases\n\nRead the [Use Cases](USE_CASES.md) file to see several examples of how to use the this module in your Defold game development projects.\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n## Issues and Suggestions\n\nFor any issues, questions, or suggestions, please [create an issue](https://github.com/Insality/defold-token/issues).\n\n\n## 👏 Contributors\n\n\u003ca href=\"https://github.com/Insality/defold-token/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=insality/defold-token\"/\u003e\n\u003c/a\u003e\n\n\n## ❤️ Support project ❤️\n\nYour donation helps me stay engaged in creating valuable projects for **Defold**. If you appreciate what I'm doing, please consider supporting me!\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInsality%2Fdefold-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInsality%2Fdefold-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInsality%2Fdefold-token/lists"}