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

Knowledge entries

Стабільне

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

A mod adds knowledge entries beside the game’s: a bool, a counter or flags, per world or per player. The game grants, sends and saves them like its own, so quests, pages and skill nodes rest on them.

load.add_knowledge(NewKnowledge) adds the entry and returns its knowledge id, the KnowledgeId::from_guid of the content id:

FieldWhat it sets
idthe entry’s content id
scopeWorld, shared by every player, or Player, each player’s own
kindBool, Counter or Flags
flagsthe bits a flags entry may hold; 0 for the others
skill_pointsthe skill points a player’s entry gives when granted
experiencethe experience value a player’s entry gives when granted

A world’s entry gives no skill points or experience: the call returns Err(Off). An entry is read on the server and the client, so a mod that adds one runs on both sides. Knowledge reads and grants it.

use enshwick::content::id;
use enshwick::content::knowledge::NewKnowledge;
use enshwick::knowledge::{Grant, KnowledgeType, Scope};
fn init(load: &mut enshwick::Load<'_>) -> Result<(), enshwick::Off> {
let shrine = load.add_knowledge(NewKnowledge {
skill_points: 1,
..NewKnowledge::new(id!("found-the-shrine"), Scope::Player, KnowledgeType::Bool)
})?;
let knowledge = load.knowledge();
load.on::<enshwick::events::PlayerJoined>(move |joined| {
let _ = knowledge.grant(joined.entity, shrine, Grant::Set);
})
}

These calls need the typed feature.

A KnowledgeQuery tests one entry, vanilla or a mod’s, where quests, journal pages and skill nodes ask for knowledge: KnowledgeQuery::is_set(id, scope) holds when a bool is set, KnowledgeQuery::at_least(id, scope, count) when a counter reaches count. A player’s entry is tested for the player the game asks about.

The same call is enshwick.content.add_knowledge{...}, at the top level of main.luau; a query is a table.

local shrine = enshwick.content.add_knowledge({
id = "you.lore:found-the-shrine",
scope = "Player",
kind = "Bool",
skill_points = 1,
})
local found = { id = shrine, scope = "Player", test = "IsSet" }

A save keeps the values of the mod’s entries while the mod runs. A save made without the mod drops them, so they read 0 when it comes back; on a server copy of server 399, the world opened and saved without errors.