Skip to content

API Hero save_traits

SolWayward edited this page Mar 4, 2026 · 1 revision

gm.hero.save_traits

Endpoint: gm.hero.save_traits

Syntax

gm.hero.save_traits <hero> <filename>

Parameters

Parameter Type Required Position Description
hero string Yes 0 Hero name, StringId, or player
filename string Yes 1 Name for the save file (without .json extension)

Description

Saves all of a hero's traits to a JSON file. The saved data includes every trait the hero has, including personality traits (Mercy, Valor, Honor, Generosity, Calculating), persona traits, political traits, role/skill traits, and any traits added by other loaded mods.

All traits are captured by iterating over TraitObject.All, ensuring complete coverage regardless of the source mod. The saved file can later be loaded onto any hero using gm.hero.load_traits. Use gm.hero.list_traits to view all saved files.

Examples

Save by Partial Name

gm.hero.save_traits derthert derthert_personality

Output:

[gm.hero.save_traits] hero: Derthert | filename: derthert_personality.json
SUCCESS: Saved Derthert's traits to: derthert_personality.json
Total traits saved: 24
Personality: Mercy: 0, Valor: 1, Honor: 2, Generosity: 0, Calculating: -1

Save Multi-Word Hero Name

gm.hero.save_traits 'Ira of the Aserai' ira_traits

Using Named Arguments

gm.hero.save_traits hero:derthert filename:king_traits

Save Player Traits

gm.hero.save_traits player my_personality

Usage Tips

Creating Personality Templates:

# Save an honorable warrior's trait profile
gm.hero.save_traits derthert noble_warrior_traits

# Apply the same personality to generated heroes
gm.hero.load_traits 'Ira of the Aserai' noble_warrior_traits

Backup Before Modification:

# Backup current traits
gm.hero.save_traits derthert derthert_backup_traits

# Make trait changes...

# Restore if needed
gm.hero.load_traits derthert derthert_backup_traits

List available files:

gm.hero.list_traits

Error Handling

Hero Not Found:

Error: No hero found matching '{query}'.

Solution: Use gm.query.hero to verify the hero name or StringId.

Multiple Matches:

Error: Multiple heroes found matching '{query}'. Please be more specific.

Solution: Use a more specific name or the exact StringId.

Filename Empty:

Error: Filename cannot be empty.

Solution: Provide a valid filename as the second argument.

Related Commands

Notes

All Traits Captured: Traits are captured via TraitObject.All, which includes all vanilla and modded traits currently active in the game session.

Personality Summary in Output: The command output shows the five core personality trait values (Mercy, Valor, Honor, Generosity, Calculating) as a quick reference alongside the total trait count.

File Overwrite: If a file with the same name already exists, it will be overwritten without warning. Use gm.hero.list_traits to check existing files first.

Single Quotes Required: The TaleWorlds console requires SINGLE QUOTES (not double quotes) for multi-word arguments.

Named and Positional Arguments: Both named (hero:value) and positional arguments are supported. Named arguments use the format argName:value with no spaces around the colon.

Last Updated: 3/3/2026

Quick Links

🏠 Home | Quick Reference | Syntax Guide


Hero Commands
Clan Commands
Kingdom Commands
Settlement Commands
Item Commands
Troop Commands
Caravan Commands
Bandit Commands
Query Commands

Clone this wiki locally