Articles on: Scripts

Dynamic Lorebook — by Icehellionx

Dynamic Lorebook

— by Icehellionx


⚠️The Dynamic Lorebook script is a derivative of the original Dynamic Lorebook script that was used during testing. This script is kept as a legacy option in case someone is brave enough to fork it and create a new variant!


The Dynamic Lorebook is a framework you can use to build lorebooks inside of Advanced Scripting. Using this script, you can adjust the character's personality, not just the scenario.


Icehellionx's v2 version of this script includes guardrails and extra features.



/**

* Dynamic Lore Book System
* Cleaned by Icehellionx
* Character reveals backstory and world knowledge based on keywords
*/

// 🟢🟢🟢 Your Lore Entries 🟢🟢🟢
var dynamicLore = [
// ——— FAMILY (6) ———
{
category: "family_mother",
keywords: ["mother", "mom", "mum", "family"],
personality: "Quietly loving but pragmatic; sees Emma’s writing as a hobby, not a profession. This creates a subtle distance, but she is well-intentioned and dotes in practical ways—care packages, reminders, recipe links. She values stability and tangible success, and she asks careful questions instead of giving orders.",
scenario: "Emma smiles small, thumb grazing her notebook as she mentions brief Sunday calls. She quotes her mom’s latest inquiry—'Are you eating proper meals?'—a gentle nudge toward the topic of the next **family dinner**. She then asks how you keep in touch with yours."
},
{
category: "family_father",
keywords: ["father", "dad", "family", "old photos"],
personality: "Quietly supportive, introspective, and gentle. He’s an emotionally available anchor for Emma—fully supportive of her creative side without needing to understand every part. He communicates love through shared silence, steady presence, and small acts.",
scenario: "Emma’s eyes warm as she recalls evening walks where her dad read aloud from a soft-spined paperback, a habit that inspired her own **night walks** for clearing her head."
},
];

// Get current conversation context
var lastMessage = context.chat.last_message.toLowerCase();
var messageCount = context.chat.message_count;

// Loop through each lore entry
for (var i = 0; i < dynamicLore.length; i++) {
var entry = dynamicLore[i];

// Check if the message count is high enough to trigger this lore (if applicable)
if (entry.minMessages && messageCount < entry.minMessages) {
continue; // Skip to the next entry if the message count is too low
}

// Check if the message contains any of the keywords
var hasKeyword = false;
for (var j = 0; j < entry.keywords.length; j++) {
if (lastMessage.includes(entry.keywords[j])) {
hasKeyword = true;
break;
}
}

// If a keyword was found, add the personality and scenario
if (hasKeyword) {
if (entry.personality) {
context.character.personality += entry.personality;
}
if (entry.scenario) {
context.character.scenario += entry.scenario;
}
}
}

Updated on: 06/09/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!