Quests Module
This module aims to handle the creation and advancement of quests for players in your game.
This module does not directly handle your quests, meaning that you will have to use the methods created to add a quest to a player, update the player's advancement in the quest, and more.
Installation
In your wally.toml file, add this to your dependencies:
Import
You have two solutions to import this module, depending if you wish to import the Controller or the Service on your own, or if you let the module give you the right code.
Configuration
A file called QuestsModule.config.lua is to be created in the folder ReplicatedStorage/Shared/Configs.
Explanation:
MaxQuestsPerUser: The maximum amount of quests a player can have at a time.
Quests: The list of all quests available.
10 Clicks: The internal name used to refer to your quest. Can be anything as long as it is unique.
Type: The type of quests that your quest fit in. This is used later in the
IncreaseCountmethod.Goal: The goal of your quest. Here, the goal is to reach 10 clicks, so put 10.
Reward: You can put whatever you want here, this is sent to all services when a player reaches the goal of a quest so you can handle this the way you like.
Usage
Client Side
This method allows you to listen to an event sent by the QuestsService and run a callback function whenever an event is received.
List of events:
OnQuestAdded: Called when a quest is added to a player. Sends the quest progress as a parameter.
OnQuestRemoved: Called when a quest is removed from a player. Sends the quest name as a parameter.
OnQuestFinished: Called when a player finishes a quest. Sends the name of the quest to the client, and the quest config to the server.
Usage
Explanation
name: The name of the event you wish to listen to.
callback: The callback function that will be run whenever this event is received.
Server Side
This method allows you to add a quest to a player. This quest will then be counted as "Started" and will be updated with the IncreaseCount method.
Usage
Explanation
player: The player to whom to add the quest.
name: The internal name of the quest to add to the player.
This method allows updating the progress of a type of quest for a player.
Usage
Explanation
player: The player who needs his quests to be updated.
type: The type of quests that needs an update.
count: The value to add to the progress.
This method allows you to remove a quest from a player.
Usage
Explanation
player: The player to whom the quest is removed.
name: The name of the quest to remove from the player.
This method allows you to retrieve the lists of all quests of a player
Usage
This method allows you to retrieve the lists of all quests of a player
Usage
Explanation
player: The player who has the quest.
name: The name of the quest to get.