Skip to content

Emberfall Example

Emberfall is the small adventure RPG used in Scribe’s feature guides. This page keeps its full template in one place. You do not need all these features to start using Scribe; Getting Started uses only coins and a setting.

DataWhat it demonstratesGuide
Coins, gems, XP, and statisticsWhole numbers with a minimumTemplates
LevelA value computed from XPDerived fields
InventoryItems with a quantity and rarityContainers
SettingsSeveral named on/off switchesFlags
LastDailyA value that expiresTimers and cooldowns

Install Scribe as described in Getting Started, then create ReplicatedStorage.Shared.EmberfallData as a ModuleScript. The feature guides require this path.

Use this module instead of the tutorial’s GameData module. Running both examples at once would create two Scribe instances on the same default transport channel.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Scribe = require(ReplicatedStorage.Packages.Scribe)
local RARITIES = { "Common", "Rare", "Epic", "Legendary" }
-- A derived calculation must give the same result on server and client.
local function levelForXp(xp: number): number
return math.min(100, math.floor(xp / 1000) + 1)
end
local template = {
Coins = Scribe.Int(0, { Min = 0 }),
Gems = Scribe.Int(0, { Min = 0 }),
Xp = Scribe.Int(0, { Min = 0 }),
Level = Scribe.Derived(Scribe.Int(1, { Min = 1, Max = 100 }), { "Xp" }, levelForXp),
Inventory = Scribe.DictOf({
Qty = Scribe.Int(1, { Min = 1, Max = 999 }),
Rarity = Scribe.Enum("Common", RARITIES),
}, { MaxKeys = 200 }),
Settings = Scribe.Flags({ "Music", "Sfx", "TutorialDone" }),
LastDaily = Scribe.Timed(false),
Stats = {
Deaths = Scribe.Int(0, { Min = 0 }),
Playtime = Scribe.Int(0, { Min = 0 }),
},
}
return Scribe({
Template = template,
ProfileStoreIndex = "EmberfallPlayerData",
ProfileKeyPrefix = "PLAYER_",
Mode = "Mock",
})

Mode = "Mock" keeps this example in memory. Read Testing before switching to real saved data.

In the server script from Getting Started, change the require to ReplicatedStorage.Shared.EmberfallData. Replace the code after the successful WaitForData check with:

data.Coins.Increment(50)
data.Xp.Increment(1200)
print(data.Level.Get()) -- 2: computed from XP
data.Settings.Enable("Music")
data.Inventory.Emberblade.Qty.Set(1)
print(data.Inventory.Emberblade.Rarity.Get()) -- Common: the item default

Writing Inventory.Emberblade.Qty creates that item and fills in its other defaults. Writing Xp recalculates Level; you cannot write Level directly.

Change the client script’s require to the same EmberfallData module. Its existing Data.Coins.Observe(...) example still works. Add this to watch the derived level:

Data.Level.Observe(function(level)
print("Level:", level)
end)

Feature guides build on this template. Shops, passes, leaderboards, and other optional systems introduce their configuration in their own guides; they are not enabled by this example alone.