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 Quest module from my Defold-Eva library.
Quest - module is a comprehensive system for managing quests in a game. It allows for the registration, tracking, and completion of quests, with various events and callbacks to handle quest-related activities.
- Quest Management - Create, start, and complete quests with ease.
- Quest Progress - Track the progress of quests and their tasks.
- Quest Events - Listen for quest-related events and adjust it for your needs.
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/5.zip
https://github.com/Insality/defold-quest/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 | 3.91 KB |
Desktop / Mobile | 7.57 KB |
Create a configuration file for the Quest module.. Place your configuration file inside your custom resources folder to ensure they are included in the build.
The configuration file should be a JSON file with the following structure:
{
"001_hidden": {
"autostart": true,
"autofinish": true,
"tasks": [
{ "action": "complete_cell", "object": "141" }
]
},
"002_destroy_them_all": {
"category": "quest",
"autostart": true,
"autofinish": true,
"required_quests": [ "001_hidden" ],
"tasks": [
{ "action": "destroy_object", "object": "tree", "required": 10 }
]
}
}
Note: for more quest fields check the
annotations.lua
to see the available properties.
When you have created the configuration file, you can initialize the Quest module with the following code:
quest.init("/resources/quest_config.json")
quest.init(quest_config_path)
quest.reset_state()
-- Events
quest.on_quest_register -- event (quest_id, quest_config)
quest.on_quest_start -- event (quest_id, quest_config)
quest.on_quest_completed -- event (quest_id, quest_config)
quest.on_quest_progress -- event (quest_id, quest_config, delta, total, task_index)
quest.on_quest_task_completed -- event (quest_id, quest_config, task_index)
quest.is_can_start -- event (quest_id, quest_config): boolean
quest.is_can_complete -- event (quest_id, quest_config): boolean
quest.is_can_event -- event (quest_id, quest_config): boolean
quest.quest_event(action, object, amount)
quest.get_current(category)
quest.get_progress(quest_id)
quest.get_completed(category)
quest.is_active(quest_id)
quest.is_completed(quest_id)
quest.is_current_with_task(action, object)
quest.is_can_start_quest(quest_id)
quest.start_quest(quest_id)
quest.is_can_complete_quest(quest_id)
quest.complete_quest(quest_id)
quest.force_complete_quest(quest_id)
quest.reset_progress(quest_id)
quest.get_quest_config(quest_id)
quest.update_quests()
quest.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!