### Instantiate and Start a Quest in GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Demonstrates how to load a QuestResource, create an instance to avoid modifying the original resource, and start it using the Questify singleton. ```gdscript @export var quest: QuestResource func _ready() -> void: var instance := quest.instantiate() Questify.start_quest(instance) ``` -------------------------------- ### Start Quest with Parameters - GDScript Source: https://context7.com/thewalruzz/godot-questify/llms.txt Demonstrates how to initiate a quest using the Questify singleton and provide optional parameters for dynamic quest content. This function loads a QuestResource, creates an instance, and starts its execution. ```gdscript extends Node @export var quest: QuestResource func _ready() -> void: # Create an instance of the quest to prevent modifying the original resource var quest_instance := quest.instantiate() # Start the quest - this triggers quest_started signal Questify.start_quest(quest_instance) # Start with parameters for dynamic quests var parametrized_quest := quest.instantiate() Questify.start_quest(parametrized_quest, { "target_enemy": "Goblin", "kill_count": 10 }) ``` -------------------------------- ### Start Parametrized Quest - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md This GDScript code shows how to start a quest with a dictionary of parameters. These parameters are then injected into condition values, allowing for dynamic quest conditions. The `Questify.start` function takes the quest resource and a dictionary of parameters. Condition nodes can reference these parameters using `{param_name}` syntax. If a single parameter is provided, its type is preserved; otherwise, the resulting value is a formatted string. ```gdscript Questify.start(quest, { "param_name": "Rat" }) ``` -------------------------------- ### Questify C# Method Execution Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Examples of executing standard Questify methods, noting the use of PascalCase for C# compatibility. ```C# Questify.StartQuest(questResource); Questify.SetQuests(questArray); ``` -------------------------------- ### Handle Quest Condition Queries Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Shows how to connect to the condition_query_requested signal to validate quest conditions against game data. This example demonstrates a basic equality check and an advanced operator-based system. ```gdscript Questify.condition_query_requested.connect( func(type: String, key: String, value: Variant, requester: QuestCondition): if type == "variable": if get_value(key) == value: requester.set_completed(true) ) ``` ```gdscript Questify.condition_query_requested.connect( func(type: String, key: String, value: Variant, requester: QuestCondition): if type.begins_with("var"): var operator := type.get_slice(":", 1) var variable := get_value(key) var result := false match operator: "eq", "==": result = variable == value "neq", "ne", "!eq", "!=": result = variable != value "lt", "<": assert(not variable is bool, "Incorrect variable type for quest condition query operator") result = variable < value "lte", "<=": assert(not variable is bool, "Incorrect variable type for quest condition query operator") result = variable <= value "gt", ">": assert(not variable is bool, "Incorrect variable type for quest condition query operator") result = variable > value "gte", ">=": assert(not variable is bool, "Incorrect variable type for quest condition query operator") result = variable >= value _: printerr("Unknown operator '%s' in quest condition query" % operator) requester.set_completed(result) ) ``` -------------------------------- ### C# Quest Manager Wrapper for Questify Source: https://context7.com/thewalruzz/godot-questify/llms.txt Provides a type-safe C# wrapper for the Questify singleton, offering convenient methods for signal connections and quest management. It allows starting, managing, and saving/loading quests using C# conventions. ```csharp using Godot; using System; public partial class QuestManager : Node { [Export] public Resource QuestResource { get; set; } public override void _Ready() { // Connect to signals using convenience methods Questify.ConnectQuestStarted(OnQuestStarted); Questify.ConnectQuestObjectiveAdded(OnObjectiveAdded); Questify.ConnectQuestObjectiveCompleted(OnObjectiveCompleted); Questify.ConnectQuestCompleted(OnQuestCompleted); Questify.ConnectConditionQueryRequested(OnConditionQuery); // Start a quest var instance = Questify.Instantiate(QuestResource); Questify.StartQuest(instance, new Godot.Collections.Dictionary { { "target", "Dragon" }, { "amount", 1 } }); } private void OnQuestStarted(Resource quest) { GD.Print($ ``` -------------------------------- ### Questify Signal Definitions Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Lists the core signals emitted by the Questify singleton to track quest lifecycle events such as starting, objective updates, and completion. ```gdscript signal quest_started(quest: QuestResource) signal quest_objective_added(quest: QuestResource, objective: QuestObjective) signal quest_objective_completed(quest: QuestResource, objective: QuestObjective) signal quest_completed(quest: QuestResource) ``` -------------------------------- ### Condition Query Handler - GDScript Source: https://context7.com/thewalruzz/godot-questify/llms.txt Implements a handler for the Questify's `condition_query_requested` signal, allowing for architecture-agnostic condition checking. This example shows a simple equality-based check for game variables. ```gdscript extends Node class_name DataManager var game_data := {} func _ready() -> void: # Simple equality-based condition handler Questify.condition_query_requested.connect( func(type: String, key: String, value: Variant, requester: QuestCondition): if type == "variable": if get_value(key) == value: requester.set_completed(true) ) ``` -------------------------------- ### Serialize and Deserialize Quest State - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md These GDScript examples show how to serialize and deserialize the entire state of active quests using the Questify singleton. `Questify.serialize()` returns an array representing the current state, which can be saved. `Questify.deserialize()` restores quests from this saved state. This method is suitable for most use cases and automatically reinstantiates and deserializes quests. ```gdscript var serialized_state := Questify.serialize() # returns Array Questify.deserialize(serialized_state) ``` -------------------------------- ### Quest State Signals - GDScript Source: https://context7.com/thewalruzz/godot-questify/llms.txt Connects to various signals emitted by the Questify singleton to track quest progression, including quest start, objective addition, objective completion, and quest completion. These signals can be used to update UI elements and trigger game events. ```gdscript extends Control @onready var quest_log: ItemList = %QuestLog @onready var objective_list: ItemList = %ObjectiveList func _ready() -> void: # Triggered when a new quest begins Questify.quest_started.connect( func(quest: QuestResource): quest_log.add_item("%s: %s" % [quest.name, quest.description]) print("Quest started: %s" % quest.name) ) # Triggered when a new objective becomes active Questify.quest_objective_added.connect( func(quest: QuestResource, objective: QuestObjective): var prefix := "OR: " if objective.is_exclusive else "" objective_list.add_item(prefix + objective.description) # Access objective metadata for map markers, etc. if objective.has_meta("marker"): var marker_position = objective.get_meta("marker") spawn_map_marker(marker_position) ) # Triggered when an objective is completed Questify.quest_objective_completed.connect( func(quest: QuestResource, objective: QuestObjective): objective_list.clear() print("Objective completed: %s" % objective.description) ) # Triggered when entire quest is finished Questify.quest_completed.connect( func(quest: QuestResource): quest_log.add_item("%s - COMPLETED!" % quest.name) give_quest_rewards(quest) ) ``` -------------------------------- ### Get Active and Completed Quests - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md This GDScript snippet shows how to retrieve arrays of active and completed quests. `Questify.get_active_quests()` returns all quests that are currently in progress, while `Questify.get_completed_quests()` returns quests that have been finished. These utility functions are useful for checking quest status or for displaying quest lists to the player. ```gdscript Questify.get_active_quests() Questify.get_completed_quests() ``` -------------------------------- ### Configure Questify Project Settings Source: https://context7.com/thewalruzz/godot-questify/llms.txt Demonstrates how to access and retrieve Questify configuration settings from Godot's ProjectSettings. It also provides a recommended pattern for optimizing performance in large-scale projects by disabling automatic polling in favor of manual updates. ```gdscript extends Node func configure_questify() -> void: # Check current settings var polling_enabled: bool = ProjectSettings.get_setting( "questify/general/update_polling" ) var polling_interval: float = ProjectSettings.get_setting( "questify/general/update_interval" ) print("Polling: %s, Interval: %s" % [polling_enabled, polling_interval]) # For production games with many quests, consider: # 1. Disable polling (set update_polling to false) # 2. Call Questify.update_quests() manually when game state changes # This provides better performance than continuous polling ``` -------------------------------- ### Project Settings Configuration Source: https://context7.com/thewalruzz/godot-questify/llms.txt Questify settings are configured through Godot's Project Settings. Key settings control condition polling behavior and localization integration. ```APIDOC ## Project Settings Configuration Questify settings are configured through Godot's Project Settings. Key settings control condition polling behavior and localization integration. ### Settings Paths - `questify/general/update_polling` (bool, default: `true`): Controls if Questify automatically polls for quest updates. - `questify/general/update_interval` (float, default: `0.5`): The interval in seconds for automatic quest updates when polling is enabled. - `questify/general/add_quests_to_pot_generation` (bool, default: `false`): Controls whether quests are added to the POT generation process. ### Example Usage (GDScript) ```gdscript extends Node func configure_questify() -> void: # Check current settings var polling_enabled: bool = ProjectSettings.get_setting( "questify/general/update_polling" ) var polling_interval: float = ProjectSettings.get_setting( "questify/general/update_interval" ) print("Polling: %s, Interval: %s" % [polling_enabled, polling_interval]) # For production games with many quests, consider: # 1. Disable polling (set update_polling to false) # 2. Call Questify.update_quests() manually when game state changes # This provides better performance than continuous polling ``` ### Performance Considerations For production games with a large number of quests, it is recommended to: 1. Disable automatic polling by setting `questify/general/update_polling` to `false`. 2. Manually call `Questify.update_quests()` when significant game state changes occur. This approach offers better performance compared to continuous polling. ``` -------------------------------- ### Questify C# Resource Management Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Methods for instantiating quest resources, updating condition states, and retrieving resource paths within the Questify system. ```C# Questify.Instantiate(Resource questResource); Questify.SetConditionCompleted(Resource questCondition, bool complete); Questify.GetResourcePath(Resource quest); ``` -------------------------------- ### Manual Serialization of QuestResource Source: https://context7.com/thewalruzz/godot-questify/llms.txt Demonstrates how to manually serialize and deserialize quest instances into dictionaries. This is useful for integrating with custom save architectures or cloud-based storage systems. ```GDScript extends Node var quest_save_data: Array = [] func save_quests_manual() -> void: quest_save_data.clear() for quest_instance in Questify.get_quests(): var serialized_quest: Dictionary = quest_instance.serialize() var quest_path: String = quest_instance.get_resource_path() quest_save_data.append({ "path": quest_path, "data": serialized_quest }) func load_quests_manual() -> void: var quests: Array[QuestResource] = [] for saved_quest in quest_save_data: var quest_resource := load(saved_quest.path) as QuestResource var instance := quest_resource.instantiate() instance.deserialize(saved_quest.data) quests.append(instance) Questify.set_quests(quests) ``` -------------------------------- ### Questify C# Signal Connections Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Convenience methods to connect to various Questify signals using C# Actions. ```C# Questify.ConnectQuestStarted(Action action); Questify.ConnectConditionQueryRequested(Action action); Questify.ConnectQuestObjectiveAdded(Action action); Questify.ConnectQuestObjectiveCompleted(Action action); Questify.ConnectQuestCompleted(Action action); ``` -------------------------------- ### Parametrized Quest Injection Source: https://context7.com/thewalruzz/godot-questify/llms.txt Shows how to use parameter injection to create dynamic quest content. This allows developers to reuse quest templates by substituting placeholders with specific values at runtime. ```GDScript extends Node @export var kill_quest: QuestResource @export var collect_quest: QuestResource func start_kill_quest(enemy_type: String, amount: int) -> void: var instance := kill_quest.instantiate() Questify.start_quest(instance, { "enemy_type": enemy_type, "kill_amount": amount }) func start_collect_quest(item_name: String, quantity: int) -> void: var instance := collect_quest.instantiate() Questify.start_quest(instance, { "item": item_name, "amount": quantity }) func display_objective(quest: QuestResource, objective: QuestObjective) -> void: var formatted := objective.description.format(quest.params) print(formatted) ``` -------------------------------- ### Manual Quest Serialization/Deserialization - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md This GDScript code provides a method for manual serialization and deserialization of individual quests. It involves using `serialize()` and `deserialize()` methods on `QuestResource` instances. Quests must be instantiated from their resources before serialization and manually added back to Questify using `Questify.set_quests()` after deserialization. This approach offers more granular control over quest state management. ```gdscript # before saving for quest_instance in quests: var serialized_quest := quest_instance.serialize() # returns Dictionary # getting resource path using this method is necessary, since instances do not have `resource_path` property var quest_path = quest_instance.get_resource_path() # ...do other serialization stuff # after loading var quests: Array[QuestResource] = [] for quest in serialized_quests: # ...load proper quest resource var instance := quest.resource.instantiate() instance.deserialize(quest.data) # quest.data could be whatever property you use to store the serialized data quests.append(instance) Questify.set_quests(quests) ``` -------------------------------- ### Format Quest Description with Params - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md This GDScript snippet illustrates how to format a quest's description using its parameters. Since quest descriptions are not automatically updated with parameter values, this `format()` function provides a way to manually inject them. It takes the quest's parameter dictionary and applies it to the description string, ensuring dynamic content is displayed correctly. ```gdscript quest_objective.description.format(quest.params) ``` -------------------------------- ### Handle Advanced Condition Queries in Questify Source: https://context7.com/thewalruzz/godot-questify/llms.txt Implements a flexible condition query system for Questify, allowing for various comparison operators (equality, inequality, less than, greater than) on game variables. It connects to the `condition_query_requested` signal to process these queries and update quest conditions accordingly. This handler requires access to game data via `get_value` and `set_value` functions. ```gdscript func setup_advanced_queries() -> void: Questify.condition_query_requested.connect( func(type: String, key: String, value: Variant, requester: QuestCondition): if type.begins_with("var"): var operator := type.get_slice(":", 1) var variable := get_value(key) var result := false match operator: type, "eq", "==": result = variable == value "neq", "ne", "!=": result = variable != value "lt", "<": result = variable < value "lte", "<=: result = variable <= value "gt", ">": result = variable > value "gte", ">=": result = variable >= value _: printerr("Unknown operator: %s" % operator) requester.set_completed(result) ) func set_value(key: String, new_value: Variant) -> void: game_data[key] = new_value func get_value(key: String) -> Variant: return game_data.get(key) ``` -------------------------------- ### Serialize and Deserialize Quest States with Questify Source: https://context7.com/thewalruzz/godot-questify/llms.txt Enables complete serialization and deserialization of all quest states, crucial for implementing save/load systems. It preserves quest progress, completed objectives, and node states. The `serialize` function returns an Array representation of quest states, which can be saved to a file. The `deserialize` function takes this Array to restore the game's quest progress. This requires `FileAccess` for file operations. ```gdscript extends Node const SAVE_PATH = "user://quest_save.dat" func save_game() -> void: # Serialize all quests to an Array var serialized_state: Array = Questify.serialize() # Save to file var file := FileAccess.open(SAVE_PATH, FileAccess.WRITE) file.store_var(serialized_state) file.close() print("Quests saved successfully") func load_game() -> void: if not FileAccess.file_exists(SAVE_PATH): return # Load from file var file := FileAccess.open(SAVE_PATH, FileAccess.READ) var serialized_state: Array = file.get_var() file.close() # Restore all quests - automatically instantiates and deserializes Questify.deserialize(serialized_state) print("Quests loaded successfully") ``` -------------------------------- ### Retrieve Meta Data in Godot GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md Demonstrates how to retrieve metadata associated with an objective node using the `get_meta` function in GDScript. This is useful for accessing dynamic data like map markers. ```gdscript objective.get_meta("marker") ``` -------------------------------- ### Control Quest Update Polling with Questify Source: https://context7.com/thewalruzz/godot-questify/llms.txt Manages the quest update mechanism in Questify. It demonstrates how to disable automatic polling for performance optimization and manually trigger updates when game data changes. This is useful for large projects where frequent polling might be detrimental. It requires setting 'Update Polling' to false in Project Settings to disable default polling. ```gdscript extends Node func _ready() -> void: # Disable automatic polling for better performance # Set in Project Settings -> Questify -> General -> Update Polling = false pass func on_data_changed() -> void: # Manually trigger quest updates when game state changes Questify.update_quests() func on_game_paused() -> void: # Pause condition polling when game is paused Questify.toggle_update_polling(false) func on_game_resumed() -> void: # Resume condition polling Questify.toggle_update_polling(true) ``` -------------------------------- ### Retrieve Active and Completed Quests with Questify Source: https://context7.com/thewalruzz/godot-questify/llms.txt Provides functionality to retrieve arrays of currently active or completed quests. This is essential for building in-game quest logs, journals, or tracking player progress. It iterates through quests and their objectives, printing their status and descriptions. This snippet assumes the existence of a `QuestResource` type with methods like `get_active_objectives` and `get_completed_objectives`. ```gdscript extends Control func update_quest_journal() -> void: # Get all active quests var active_quests: Array[QuestResource] = Questify.get_active_quests() for quest in active_quests: print("Active: %s" % quest.name) # Get active objectives for this quest var objectives := quest.get_active_objectives() for objective in objectives: print(" - %s" % objective.description) # Get all completed quests var completed_quests: Array[QuestResource] = Questify.get_completed_quests() for quest in completed_quests: print("Completed: %s" % quest.name) # Get completed objectives var done_objectives := quest.get_completed_objectives() for objective in done_objectives: print(" - [DONE] %s" % objective.description) ``` -------------------------------- ### Accessing QuestObjective Metadata Source: https://context7.com/thewalruzz/godot-questify/llms.txt Explains how to retrieve custom metadata attached to quest objectives. This is used for game-specific features like map markers, NPC targeting, or reward previews. ```GDScript extends Node func _ready() -> void: Questify.quest_objective_added.connect(on_objective_added) func on_objective_added(quest: QuestResource, objective: QuestObjective) -> void: if objective.has_meta("marker"): var marker_pos: Vector2 = objective.get_meta("marker") create_map_marker(marker_pos, objective.description) if objective.has_meta("target_npc"): var npc_id: String = objective.get_meta("target_npc") highlight_npc(npc_id) if objective.has_meta("reward"): var reward: Dictionary = objective.get_meta("reward") show_reward_preview(reward) func create_map_marker(pos: Vector2, label: String) -> void: pass func highlight_npc(npc_id: String) -> void: pass func show_reward_preview(reward: Dictionary) -> void: pass ``` -------------------------------- ### Toggle Quest Update Polling - GDScript Source: https://github.com/thewalruzz/godot-questify/blob/main/README.md This GDScript snippet demonstrates how to toggle the quest update polling mechanism on or off. This is useful for pausing updates when the game is paused or for manual control. The function `toggle_update_polling` accepts a boolean value, where `false` disables polling and `true` enables it. This functionality is dependent on the 'Update Polling' setting in Project Settings. ```gdscript Questify.toggle_update_polling(false) # or `true` if enabling it back. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.