Starred

Recents

View all

Professional plan

WL

williamgarylea@yahoo.com

WL

Toggling NPC Name Display in Skyrim

Share

WL

In Skyrim Display NPC Characters are labeled with a text entry. How can I turn tis off/on

Edit

To toggle the display of NPC names in Skyrim, you'll need to use a console command. Here's how to do it:

  1. Open the console by pressing the tilde key (~) - it's usually located below the Esc key on your keyboard
  2. Type the following command:

    Copy

    tm

  3. Press Enter

The tm command toggles all UI elements (including NPC names, compass, health bars, etc.). Each time you enter this command, it will switch between showing and hiding all UI elements.

If you want more control and only hide the NPC names while keeping other UI elements, you can try:

  1. Open the console with the tilde key
  2. Type:

    Copy

    tfc

  3. This toggles "free camera" mode which often hides NPC names while letting you keep other UI elements

You can also adjust display settings through the game's menu:

  • Press Esc to open the menu
  • Go to Settings → Display
  • Look for "HUD Opacity" and adjust it as needed

Would you like me to suggest any mods that give you more control over which UI elements are displayed?

Retry

WL

Yes, I want to control the display from a script without accessing the console commands

Edit

For scripting control over UI elements in Skyrim without using console commands, you'll want to look at SKSE (Skyrim Script Extender) and related mods. Here's how to approach this:

SkyUI and MCM (Mod Configuration Menu)

  1. Install SKSE: This extends Skyrim's scripting capabilities
    • Download from skse.silverlock.org
    • Install according to the instructions for your Skyrim version
  2. Install SkyUI: This provides a framework for UI customization
    • Available on Nexus Mods
    • Includes MCM (Mod Configuration Menu) for script-accessible settings
  3. Less HUD or iHUD (Immersive HUD): These mods specifically allow toggling various HUD elements via scripts
    • Both are configurable through MCM and expose functions for scripts

Script Example

Here's an example of how you might toggle NPC names using Papyrus scripting with one of these mods installed:

papyrus

Copy

Scriptname MyToggleHUD extends Quest Function ToggleNPCNames(bool shouldShow) If(Game.GetModByName("iHUD.esp") != 255) ; Check if iHUD is installed Debug.Notification("Toggling NPC names via iHUD") iHUD.SetNameDisplay(shouldShow) ; Pseudo-code - actual function depends on the mod ElseIf(Game.GetModByName("Less HUD.esp") != 255) Debug.Notification("Toggling NPC names via Less HUD") LessHUD.ToggleActorNames(shouldShow) ; Pseudo-code Else Debug.Notification("No HUD mod found to toggle names") EndIf EndFunction

Alternative: JContainers and PapyrusUtil

For more advanced scripting capabilities:

  1. Install JContainers and PapyrusUtil
  2. Create a mod with custom SKSE plugin that exposes functions to toggle specific UI elements
  3. Call these functions from your Papyrus scripts

Custom SKSE Plugin

If you're comfortable with C++ development in Visual Studio (which your preferences indicate), you could create a custom SKSE plugin that directly manipulates the game's UI system:

  1. Set up the SKSE plugin development environment
  2. Create functions that toggle specific UI elements
  3. Expose these functions to Papyrus for use in your scripts

Would you like me to elaborate on any of these approaches? I could provide more specific information about creating a custom SKSE plugin using C++ since that matches your development preferences.

Retry

Claude does not have internet access. Links provided may not be accurate or up to date.

WL

Yes I would like to see how a SKSE plugin could controle the various HUD/ Menu Items and also How I could Include these functions in my own Existing SKSE Plugin. By this I mean I woud pass a control variable to the C++ function and It would make the appropriate HUD/Menu changed as It was called and returned.

Edit

Creating SKSE Plugin Functions to Control HUD Elements

I'll show you how to implement HUD control functionality in your existing SKSE plugin using C++. This approach gives you precise control over UI elements without relying on other mods.

Core Implementation

First, here's how to add HUD control functions to your existing SKSE plugin:

cpp

Copy

#include "common/IDebugLog.h" #include "skse64/PluginAPI.h" #include "skse64/GameMenus.h" #include "skse64/PapyrusVM.h" #include "skse64/PapyrusNativeFunctions.h" // Function to toggle NPC names display bool ToggleNPCNames(StaticFunctionTag* base, bool showNames) { // Get the HUD menu UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); if (!uiStrHolder) return false; MenuManager* mm = MenuManager::GetSingleton(); if (!mm) return false; // Get the HUD menu IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu) return false; GFxMovieView* view = hudMenu->movie; if (!view) return false; // Using GFx to set the visibility of the actor name display component GFxValue args[1]; args[0].SetBool(showNames); // Call the ActionScript function that controls name display // Note: The exact path depends on how the HUD is structured view->Invoke("_root.HUDMovieBaseInstance.SetActorNameVisible", nullptr, args, 1); return true; } // Function to control compass visibility bool ToggleCompass(StaticFunctionTag* base, bool showCompass) { UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); MenuManager* mm = MenuManager::GetSingleton(); if (!uiStrHolder || !mm) return false; IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu || !hudMenu->movie) return false; GFxValue args[1]; args[0].SetBool(showCompass); hudMenu->movie->Invoke("_root.HUDMovieBaseInstance.CompassShoutMeterHolder._visible", nullptr, args, 1); return true; } // Master function to control multiple HUD elements at once bool ControlHUDElements(StaticFunctionTag* base, bool showNPCNames, bool showCompass, bool showHealth, bool showMagicka, bool showStamina) { UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); MenuManager* mm = MenuManager::GetSingleton(); if (!uiStrHolder || !mm) return false; IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu || !hudMenu->movie) return false; GFxMovieView* view = hudMenu->movie; // Control NPC names GFxValue nameArgs[1]; nameArgs[0].SetBool(showNPCNames); view->Invoke("_root.HUDMovieBaseInstance.SetActorNameVisible", nullptr, nameArgs, 1); // Control compass GFxValue compassArgs[1]; compassArgs[0].SetBool(showCompass); view->Invoke("_root.HUDMovieBaseInstance.CompassShoutMeterHolder._visible", nullptr, compassArgs, 1); // Control health/magicka/stamina bars GFxValue barsArgs[1]; barsArgs[0].SetBool(showHealth && showMagicka && showStamina); view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder._visible", nullptr, barsArgs, 1); // You can add more specific controls for individual bars if needed return true; }

Registering Functions with Papyrus

Next, register these functions to expose them to Papyrus scripts:

cpp

Copy

bool RegisterHUDFunctions(VMClassRegistry* registry) { registry->RegisterFunction( new NativeFunction1<StaticFunctionTag, bool, bool>("ToggleNPCNames", "YourModNamespace", ToggleNPCNames, registry)); registry->RegisterFunction( new NativeFunction1<StaticFunctionTag, bool, bool>("ToggleCompass", "YourModNamespace", ToggleCompass, registry)); registry->RegisterFunction( new NativeFunction5<StaticFunctionTag, bool, bool, bool, bool, bool, bool> ("ControlHUDElements", "YourModNamespace", ControlHUDElements, registry)); return true; }

Then, in your plugin's main initialization function:

cpp

Copy

bool SKSEPlugin_Load(const SKSEInterface* skse) { // Your existing plugin initialization code // Register Papyrus functions papyrus->Register(RegisterHUDFunctions); return true; }

Creating the Papyrus Script Interface

Create a Papyrus script to use your new functions:

papyrus

Copy

Scriptname YourModNamespace Native Hidden ; Toggle NPC name display Function ToggleNPCNames(bool showNames) global native ; Toggle compass display Function ToggleCompass(bool showCompass) global native ; Control multiple HUD elements at once Function ControlHUDElements(bool showNPCNames, bool showCompass, bool showHealth, bool showMagicka, bool showStamina) global native

Implementation Notes and Challenges

  1. Flash UI Paths: The actual paths to UI elements in the Flash hierarchy may vary based on your Skyrim version. You'll need to use a tool like Adobe Flash Decompiler to inspect Interface/HUD.swf to find exact paths.
  2. HUD Components: Skyrim's HUD is implemented in Flash (ActionScript), and SKSE interacts with it through the GFx interface. The core components include:
    • HUDMovieBaseInstance: Main HUD container
    • ActorInfoHolder: NPC names and health bars
    • CompassShoutMeterHolder: Compass and shout meter
    • HealthMagickaStaminaHolder: Player status bars
  3. Debugging Tips:
    • Use _global.gfxLoader.PrintASMethods(true) in the Flash environment to dump available methods
    • Add logging in your C++ code to verify paths and function calls

Advanced Integration Example

Here's how to integrate this with an existing plugin using a configuration structure:

cpp

Copy

// In your header file struct HUDConfiguration { bool showNPCNames; bool showCompass; bool showHealth; bool showMagicka; bool showStamina; bool showQuestMarkers; bool showEnemyHealthBars; // Add more as needed }; // Function to apply a configuration bool ApplyHUDConfiguration(StaticFunctionTag* base, HUDConfiguration* config); // In your implementation file bool ApplyHUDConfiguration(StaticFunctionTag* base, HUDConfiguration* config) { if (!config) return false; return ControlHUDElements(base, config->showNPCNames, config->showCompass, config->showHealth, config->showMagicka, config->showStamina); }

This approach allows you to maintain a consistent HUD state in your plugin and apply changes as needed.

Would you like me to expand on any particular aspect of this implementation, such as more details on the Flash UI structure or handling specific HUD elements?

Retry

WL

Could you expand on determining a configuration turning off eliments adn then restoring the original HUD/Menu state

Edit

Managing HUD Configuration States in SKSE Plugins

To implement a system that can turn off HUD elements and then restore them to their original state, you'll need to track the current state of each HUD element. Here's an expanded implementation with state management:

Configuration Management Class

First, let's create a class to manage HUD states:

cpp

Copy

// HUDManager.h class HUDManager { private: // Singleton instance static HUDManager* instance; // Current state of each HUD element struct HUDState { bool npcNamesVisible; bool compassVisible; bool healthBarVisible; bool magickaBarVisible; bool staminaBarVisible; bool enemyHealthBarsVisible; bool questMarkersVisible; bool crosshairVisible; bool subtitlesVisible; // Add other elements as needed }; // Original state (for restoration) HUDState originalState; // Current state HUDState currentState; // Flag to track if we've saved the original state bool originalStateSaved; // Private constructor for singleton HUDManager(); // Apply current state to the game bool ApplyCurrentState(); public: // Get singleton instance static HUDManager* GetSingleton(); // Save current HUD state as original bool SaveOriginalState(); // Restore to original state bool RestoreOriginalState(); // Set individual element states bool SetNPCNamesVisible(bool visible); bool SetCompassVisible(bool visible); bool SetHealthBarVisible(bool visible); // ... other setters ... // Get current states bool AreNPCNamesVisible() const; bool IsCompassVisible() const; // ... other getters ... // Apply a preset configuration bool ApplyPreset(UInt32 presetId); };

Implementation of HUD Manager

cpp

Copy

// HUDManager.cpp #include "HUDManager.h" #include "skse64/GameMenus.h" HUDManager* HUDManager::instance = nullptr; HUDManager::HUDManager() { // Initialize with defaults assuming everything is visible currentState = { true, // npcNamesVisible true, // compassVisible true, // healthBarVisible true, // magickaBarVisible true, // staminaBarVisible true, // enemyHealthBarsVisible true, // questMarkersVisible true, // crosshairVisible true // subtitlesVisible }; originalState = currentState; originalStateSaved = false; } HUDManager* HUDManager::GetSingleton() { if (!instance) instance = new HUDManager(); return instance; } bool HUDManager::SaveOriginalState() { // Get HUD menu UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); MenuManager* mm = MenuManager::GetSingleton(); if (!uiStrHolder || !mm) return false; IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu || !hudMenu->movie) return false; GFxMovieView* view = hudMenu->movie; // Get NPC names visibility GFxValue result; if (view->Invoke("_root.HUDMovieBaseInstance.ActorInfoHolder._visible", &result, nullptr, 0)) originalState.npcNamesVisible = result.GetBool(); // Get compass visibility if (view->Invoke("_root.HUDMovieBaseInstance.CompassShoutMeterHolder._visible", &result, nullptr, 0)) originalState.compassVisible = result.GetBool(); // Get health bar visibility if (view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.HealthRect._visible", &result, nullptr, 0)) originalState.healthBarVisible = result.GetBool(); // Get magicka bar visibility if (view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.MagickaRect._visible", &result, nullptr, 0)) originalState.magickaBarVisible = result.GetBool(); // Get stamina bar visibility if (view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.StaminaRect._visible", &result, nullptr, 0)) originalState.staminaBarVisible = result.GetBool(); // Get enemy health bars visibility if (view->Invoke("_root.HUDMovieBaseInstance.EnemyHealthHolder._visible", &result, nullptr, 0)) originalState.enemyHealthBarsVisible = result.GetBool(); // Get quest markers visibility if (view->Invoke("_root.HUDMovieBaseInstance.QuestUpdateBaseInstance._visible", &result, nullptr, 0)) originalState.questMarkersVisible = result.GetBool(); // Get crosshair visibility if (view->Invoke("_root.HUDMovieBaseInstance.CrosshairInstance._visible", &result, nullptr, 0)) originalState.crosshairVisible = result.GetBool(); // Get subtitle visibility if (view->Invoke("_root.HUDMovieBaseInstance.SubtitleTextHolder._visible", &result, nullptr, 0)) originalState.subtitlesVisible = result.GetBool(); // Update current state to match original currentState = originalState; originalStateSaved = true; _MESSAGE("Original HUD state saved"); return true; } bool HUDManager::RestoreOriginalState() { if (!originalStateSaved) { _MESSAGE("Cannot restore original state - no state was saved"); return false; } // Set current state back to original currentState = originalState; // Apply the original state to the game return ApplyCurrentState(); } bool HUDManager::ApplyCurrentState() { UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); MenuManager* mm = MenuManager::GetSingleton(); if (!uiStrHolder || !mm) return false; IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu || !hudMenu->movie) return false; GFxMovieView* view = hudMenu->movie; // Set NPC names visibility GFxValue npcNameArgs[1]; npcNameArgs[0].SetBool(currentState.npcNamesVisible); view->Invoke("_root.HUDMovieBaseInstance.ActorInfoHolder._visible", nullptr, npcNameArgs, 1); // Set compass visibility GFxValue compassArgs[1]; compassArgs[0].SetBool(currentState.compassVisible); view->Invoke("_root.HUDMovieBaseInstance.CompassShoutMeterHolder._visible", nullptr, compassArgs, 1); // Set health bar visibility GFxValue healthArgs[1]; healthArgs[0].SetBool(currentState.healthBarVisible); view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.HealthRect._visible", nullptr, healthArgs, 1); // Set magicka bar visibility GFxValue magickaArgs[1]; magickaArgs[0].SetBool(currentState.magickaBarVisible); view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.MagickaRect._visible", nullptr, magickaArgs, 1); // Set stamina bar visibility GFxValue staminaArgs[1]; staminaArgs[0].SetBool(currentState.staminaBarVisible); view->Invoke("_root.HUDMovieBaseInstance.HealthMagickaStaminaHolder.StaminaRect._visible", nullptr, staminaArgs, 1); // Continue for other HUD elements... _MESSAGE("Applied HUD state configuration"); return true; } // Individual element setters bool HUDManager::SetNPCNamesVisible(bool visible) { currentState.npcNamesVisible = visible; UIStringHolder* uiStrHolder = UIStringHolder::GetSingleton(); MenuManager* mm = MenuManager::GetSingleton(); if (!uiStrHolder || !mm) return false; IMenu* hudMenu = mm->GetMenu(&uiStrHolder->hudMenu); if (!hudMenu || !hudMenu->movie) return false; GFxValue args[1]; args[0].SetBool(visible); hudMenu->movie->Invoke("_root.HUDMovieBaseInstance.ActorInfoHolder._visible", nullptr, args, 1); return true; } // Implement other setters similarly... // Preset configurations bool HUDManager::ApplyPreset(UInt32 presetId) { switch (presetId) { case 0: // Combat preset - focus on enemies and health currentState.npcNamesVisible = true; currentState.compassVisible = true; currentState.healthBarVisible = true; currentState.magickaBarVisible = true; currentState.staminaBarVisible = true; currentState.enemyHealthBarsVisible = true; currentState.questMarkersVisible = false; currentState.crosshairVisible = true; currentState.subtitlesVisible = false; break; case 1: // Exploration preset - focus on navigation currentState.npcNamesVisible = true; currentState.compassVisible = true; currentState.healthBarVisible = false; currentState.magickaBarVisible = false; currentState.staminaBarVisible = false; currentState.enemyHealthBarsVisible = false; currentState.questMarkersVisible = true; currentState.crosshairVisible = true; currentState.subtitlesVisible = true; break; case 2: // Clean screenshot mode - hide everything currentState.npcNamesVisible = false; currentState.compassVisible = false; currentState.healthBarVisible = false; currentState.magickaBarVisible = false; currentState.staminaBarVisible = false; currentState.enemyHealthBarsVisible = false; currentState.questMarkersVisible = false; currentState.crosshairVisible = false; currentState.subtitlesVisible = false; break; default: return false; } return ApplyCurrentState(); }

Exposing to Papyrus

Now, let's expose these functions to Papyrus:

cpp

Copy

// Define native functions for Papyrus bool SaveHUDState(StaticFunctionTag* base) { return HUDManager::GetSingleton()->SaveOriginalState(); } bool RestoreHUDState(StaticFunctionTag* base) { return HUDManager::GetSingleton()->RestoreOriginalState(); } bool SetNPCNamesVisible(StaticFunctionTag* base, bool visible) { return HUDManager::GetSingleton()->SetNPCNamesVisible(visible); } bool ApplyHUDPreset(StaticFunctionTag* base, UInt32 presetId) { return HUDManager::GetSingleton()->ApplyPreset(presetId); } // Register these functions with Papyrus bool RegisterHUDFunctions(VMClassRegistry* registry) { registry->RegisterFunction( new NativeFunction0<StaticFunctionTag, bool>("SaveHUDState", "YourModNamespace", SaveHUDState, registry)); registry->RegisterFunction( new NativeFunction0<StaticFunctionTag, bool>("RestoreHUDState", "YourModNamespace", RestoreHUDState, registry)); registry->RegisterFunction( new NativeFunction1<StaticFunctionTag, bool, bool>("SetNPCNamesVisible", "YourModNamespace", SetNPCNamesVisible, registry)); registry->RegisterFunction( new NativeFunction1<StaticFunctionTag, bool, UInt32>("ApplyHUDPreset", "YourModNamespace", ApplyHUDPreset, registry)); // Register other functions... return true; }

Papyrus Script Interface

papyrus

Copy

Scriptname YourModNamespace Native Hidden ; Save current HUD state to restore later Function SaveHUDState() global native ; Restore HUD to original saved state Function RestoreHUDState() global native ; Individual element controls Function SetNPCNamesVisible(bool visible) global native Function SetCompassVisible(bool visible) global native Function SetHealthBarVisible(bool visible) global native ; ... other functions ... ; Apply a preset configuration ; 0 = Combat preset ; 1 = Exploration preset ; 2 = Clean screenshot mode (hide all) Function ApplyHUDPreset(int presetId) global native

Usage in a Mod Script

papyrus

Copy

Scriptname MyCustomHUDScript extends Quest Event OnInit() ; Save the initial HUD state when the mod initializes YourModNamespace.SaveHUDState() EndEvent Function EnterCombatMode() ; Apply combat-focused HUD preset YourModNamespace.ApplyHUDPreset(0) EndFunction Function EnterExplorationMode() ; Apply exploration-focused HUD preset YourModNamespace.ApplyHUDPreset(1) EndFunction Function TakeScreenshot() ; Hide all HUD elements for clean screenshot YourModNamespace.ApplyHUDPreset(2) ; Wait for 5 seconds Utility.Wait(5.0) ; Restore previous state YourModNamespace.RestoreHUDState() EndFunction Function OnModShutdown() ; Make sure to restore original HUD state when mod is disabled YourModNamespace.RestoreHUDState() EndFunction

Implementation Considerations

  1. Initialization Timing: Make sure to save the original state at an appropriate time - typically when your mod initializes or when a power/spell/ability is first used.
  2. Redundancy Handling: Implement checks to prevent saving over the original state accidentally.
  3. Menu Changes: Skyrim's menus can reload or change during gameplay. Consider adding a listener for menu open/close events to reapply your HUD configuration when needed:

cpp

Copy

EventResult HUDManager::ReceiveEvent(MenuOpenCloseEvent* evn, EventDispatcher<MenuOpenCloseEvent>* dispatcher) { // If the HUD menu was just opened if (evn->opening && evn->menuName == UIStringHolder::GetSingleton()->hudMenu) { // Reapply current state after a short delay // (menu might not be fully initialized immediately) TaskDelegate* task = new TaskDelegate([this]() { this->ApplyCurrentState(); }); TaskInterface::AddTask(task, 0.1f); } return kEvent_Continue; }

  1. Cross-Mod Compatibility: Consider adding a way for other mods to query your HUD state to avoid conflicts.
  2. Performance: Cache the HUD menu and GFx movie view when possible to avoid repeated lookups.
  3. Settings Storage: Add MCM support to save user preferences for HUD configurations between game sessions.

This implementation provides a complete framework for managing, storing, and restoring HUD element configurations in your SKSE plugin. The key advantage is maintaining the original state so users can always return to how their game was configured before your mod made changes.

Retry

Claude can make mistakes. Please double-check responses.

 

3.7 Sonnet