<%*

// 1) Prompt for Place name const title = await tp.system.prompt(ā€œEnter Place Nameā€, tp.file.title); if (!title) return; await tp.file.rename(title);

// 2) Gather all container notes from 2-World/Hubs const containerFiles = tp.app.vault.getMarkdownFiles() .filter(f ⇒ f.path.startsWith(ā€œ2-World/Hubs/ā€));

const placeholderLabel = ā€šŸŒ€ No Hub Selectedā€; const placeholderPath = ā€œplaceholderā€;

// 3) Build suggester options const containerChoices = [placeholderLabel, …containerFiles.map(f ⇒ f.basename)]; const containerValues = [placeholderPath, …containerFiles.map(f ⇒ f.path)]; const chosenPath = await tp.system.suggester(containerChoices, containerValues, true); if (!chosenPath) return;

// 4) Build wiki-link or fallback let wikiLink = null; if (chosenPath !== placeholderPath) { const alias = chosenPath.split(ā€/ā€œ).pop().replace(/.md{chosenPath}|${alias}]]`; }

// 5) Pick a category from your list const categoryOptions = [ ā€œCommerceā€, ā€œAgricultureā€, ā€œMilitaryā€, ā€œPhilosophyā€, ā€œIndustrialā€, ā€œNestingā€, ā€œGovernmentā€ ]; const chosenCat = await tp.system.suggester(categoryOptions, categoryOptions, true); if (!chosenCat) return;

// 6) Write to frontmatter setTimeout(() ⇒ { const file = tp.file.find_tfile(tp.file.path(true)); if (!file) return; app.fileManager.processFrontMatter(file, fm ⇒ { fm[ā€œMyContainerā€] = wikiLink ?? ā€œNoneā€; fm[ā€œMyCategoryā€] = chosenCat; }); }, 100);

%>

Parent Hub: INPUT[suggester(optionQuery(#Category/Hub)):MyContainer]

Column

Place Name

INPUT[select(
option(1, ā„¹ļøGeneral Info),
option(2, šŸƒā€ā™‚ļøā€āž”ļøNPCs),
option(3, šŸ“GM Notes),
class(tabbed)
)]

Tabbed

NOTE

INPUT[select(
option(1, šŸ›’Selling),
option(2, šŸŖ™Buying),
option(3, šŸ› ļøServices),
option(4, 🤐Rumours),
class(tabbed)
)]

Tabbed


General

Select Settlement: INPUT[suggester(optionQuery(#Category/Hub)):MyContainer]

Select Category: INPUT[template-place-category][:MyCategory]

This is the places description.

NPCs

BUTTON[button_person] The following people are associated with this place.

properties:
  file.name:
    displayName: Star Systems Name
  note.MyCategory:
    displayName: Type of Star System
  note.char_race:
    displayName: Race
  note.char_gender:
    displayName: Gender
  note.char_age:
    displayName: Age
views:
  - type: cards
    name: Star Systems - Cards
    filters:
      and:
        - file.folder == "2-World/People"
        - list(MyContainer).contains(this)
        - char_status.contains("Alive")
    order:
      - file.name
      - char_age
      - char_gender
      - char_race
    image: note.image
  - type: table
    name: Star Systems - Table
    filters:
      and:
        - file.folder == "2-World/People"
        - list(MyContainer).contains(this)
        - char_status.contains("Alive")
    order:
      - file.name
    sort:
      - property: file.name
        direction: DESC
    columnSize:
      file.name: 182
 

GM Notes

Make notes of what you need to track in the town here.

Selling

The following items are available for purchase.

// This dataviewjs code grabs a random item(s) from the folder below. You can remove this if that's not useful. It's an example of what's possible. 
// 1. grab all pages in the folder
let pages = dv.pages('"3-Mechanics/Items"').values;
 
// 2. shuffle
for (let i = pages.length - 1; i > 0; i--) {
  const j = Math.floor(Math.random() * (i + 1));
  [pages[i], pages[j]] = [pages[j], pages[i]];
}
 
// 3. take the first X where (0, X) should be the number of items to return
let pick = pages.slice(0, 1);
 
// 4. render table of clickable links + Gender
dv.table(
  ["Random Item", "cost", "weight"],
  pick.map(p => [
    dv.fileLink(p.file.path),        // clickable note link
    p.cost ?? "—",                  // frontmatter field (falls back to ā€œā€”ā€ if missing)
    p.weight ?? "—"                  // frontmatter field (falls back to ā€œā€”ā€ if missing)
  ])
);

Buying

List of things this merchant will purchase.

ItemCostWeight
Item 11gpL
Item 21cp-

Services

Services offered.

ItemCostWeight
Service 11gpL
Service 21cp-

Rumours

Anything the party might over hear?

Image