Перейти до вмісту
EnshwickEnshwickальфа
Завантажити

Quests and journal pages

Цей контент ще не доступний вашою мовою.

A mod adds quests and lore pages to the journal and changes the game’s quests. A quest’s steps show and complete on knowledge; its rewards pay out when the last step completes. The game’s own screens draw them.

load.add_quest(NewQuest) adds the quest beside the game’s and returns its quest id. The quest id is a player’s bool the game sets when it pays the quest, as for its own quests; Knowledge reads it.

FieldWhat it sets
idthe quest’s content id
nameits title’s text tag
sourcewho gives it, which groups it in the journal
kindPlayerQuest, WorldQuest or Auto
mainwhether the journal lists it as a main quest
for_all_playerswhether one player’s completion unlocks it for all
stepsits steps, in order
rewardsitems by GUID and experience values

Each QuestStep shows while shown_when holds and is done once done_when holds; progress lists parts the journal counts. A mod moves the quest on by granting the knowledge its steps ask for. Texts come from the mod’s texts, in every language it gives (see Texts).

use enshwick::content::{Guid, id};
use enshwick::content::journal::{NewQuest, QuestReward, QuestStep};
use enshwick::content::knowledge::{KnowledgeQuery, NewKnowledge};
use enshwick::knowledge::{KnowledgeType, Scope};
fn init(load: &mut enshwick::Load<'_>, torch: Guid) -> Result<(), enshwick::Off> {
let given = load.add_knowledge(NewKnowledge::new(id!("trail-given"), Scope::Player, KnowledgeType::Bool))?;
let wood = load.add_knowledge(NewKnowledge::new(id!("trail-wood"), Scope::Player, KnowledgeType::Counter))?;
let step = QuestStep::new(
id!("trail.step").guid(),
id!("trail.step.text").guid(),
KnowledgeQuery::is_set(given, Scope::Player),
KnowledgeQuery::at_least(wood, Scope::Player, 3),
);
load.add_quest(NewQuest {
rewards: vec![QuestReward::Item(torch)],
..NewQuest::new(id!("trail"), id!("trail.name").guid(), vec![step])
})?;
Ok(())
}

On a server copy of server 399, the server’s journal listed a mod’s quest beside the game’s 188.

load.add_journal_page(NewJournalPage) adds a lore page listed under its category’s text tag. Each PageEntry shows once its shown_when holds.

load.change_quest(quest, QuestChange) changes a vanilla quest in memory:

  • rewards replaces its rewards, and add_rewards adds after them;
  • for_all_players sets whether one player’s completion unlocks it for all;
  • steps replaces the knowledge a step shows or completes on.

Mods that change one quest change it in load order, each on the one before’s result. knowledge.quests() lists the quest ids of the running game.

knowledge.quest_progression(player) says whether a player follows the quests on their own rather than with the world, and knowledge.set_quest_progression(player, personal) sets it, as the journal’s own setting does. The server sets it and the game sends it to the clients.

These calls need the typed feature.

The same calls are enshwick.content.add_quest{...}, enshwick.content.add_journal_page{...} and enshwick.content.change_quest(id, {...}) at the top level of main.luau, and enshwick.knowledge.quest_progression(player) and set_quest_progression(player, personal) while the world runs.

local given = enshwick.content.add_knowledge({ id = "you.trail:given", scope = "Player", kind = "Bool" })
local is_given = { id = given, scope = "Player", test = "IsSet" }
enshwick.content.add_quest({
id = "you.trail:trail",
name = enshwick.content.guid("you.trail:trail.name"),
source = "None",
kind = "PlayerQuest",
steps = { {
name = enshwick.content.guid("you.trail:trail.step"),
text = enshwick.content.guid("you.trail:trail.step.text"),
shown_when = is_given,
done_when = is_given,
} },
rewards = { { Item = "<the GUID of a vanilla item>" } },
})

The journal is drawn on the client from its own copy of the data, so a mod that adds a quest or a page runs on both sides.