A comprehensive NUI API, with Dialog Creator, Popup and aaddon module systems for Neverwinter Nights: Enhanced Edition (NWN:EE).
The Carcerian NUI System provides a complete framework for creating professional player-facing UI windows, popups, signs, and dialogs in NWN:EE. Built entirely in NWScript with strict architectural standards and comprehensive documentation.
Current Status: v1.0 - Production Ready
Language: NWScript (100% NWN:EE compatible)
Files: 41 NSS modules
Functions: 65+ popup/dialog functions
Lines of Code: ~8,500+ (core API)
- NUI_PopupMessage - Simple messages with OK button
- NUI_PopupSign - Large sign displays with portrait images (XML layout)
- NUI_PopupError/Success/Warning/Info - Color-coded message types
- NUI_PopupDialog - Custom dialogs with flexible layouts
- NUI_PopupYesNo/Choice - User choice prompts
Architecture
nui_api.nss- Main API entry pointnui_api_popup.nss- All 65+ popup functionsnui_api_handle.nss- Event handler routingnui_api_config.nss- Configuration constantsnui_api_json.nss- JSON utility functionsnui_aoe.nss- AOE integration for window lifecycle
Subsystems
nui_body_api.nss/nui_body_adj.nss- Body appearance customizationnui_cf_api.nss- Crafting systemnui_ct_api.nss/nui_ct_eq.nss- Customization/equipmentnui_em_api.nss/nui_emote.nss- Emote systemnui_plc_api.nss/nui_plc.nss- Placeable integrationnui_pvp_api.nss/nui_pvp.nss- PvP systemnui_rest_api.nss/nui_rest.nss- Rest/healingnui_vfx_api.nss/nui_vfx.nss- Visual effectsnui_shop.nss/nui_shop_evt.nss- Commercenui_talk.nss/nui_talk_evt.nss- NPC dialogue
Utilities & Support
nui_handler.nss- Main event dispatchernui_log.nss- Logging systemnui_persist.nss/nui_safe_per.nss/nui_tailor_per.nss- Persistencenui_data.nss- Data managementnui_validate.nss- Input validationnui_doc.nss- Documentationnui_enter.nss/nui_leave.nss/nui_load.nss- Lifecyclenui_mod_event.nss/nui_event.nss- Module events
Window Properties (nProps)
- Resizable windows
- Collapsible windows
- Closable windows (X button)
- Border styling
- Transparent backgrounds
- Predefined flag combinations
AOE Integration
- Windows tied to Area of Effect objects
- Auto-close when player leaves AOE radius
- Sign placement at object location
- Configurable AOE radius
XML Layout Support
- Professional portrait display (XML format)
- Complex layouts with row/column structure
- Dynamic image aspect ratios
- Centered content positioning
Portrait Images
- Display object portraits in signs
- Fallback to default portrait if not set
- Proper XML image element formatting
- Aspect ratio fitting
-
Copy all NSS files to your NWN:EE module scripts directory
-
Compile with NWN:EE toolset (all files compile without errors)
-
Add event hooks to module:
- Module OnNUI Event →
nui_mod_event - Area OnEnter →
nui_enter - Area OnExit →
nui_leave - Module Load →
nui_load
- Module OnNUI Event →
-
Attach to placeables:
- OnUsed event →
nui_example(shows how to use NUI_PopupSign)
- OnUsed event →
#include "nui_api"
void main()
{
object oPC = GetFirstPC();
NUI_PopupMessage(oPC, "Title", "Message text");
}
#include "nui_api"
void main()
{
object oPC = GetLastUsedBy();
// Attach to sign placeable OnUsed event
// Sign uses OBJECT_SELF for:
// - Name (window title)
// - Description (window content)
// - Portrait (portrait image)
NUI_PopupSign(oPC);
}
NUI_PopupError(oPC, "Error Title", "Error message");
NUI_PopupSuccess(oPC, "Success", "Action completed");
NUI_PopupInfo(oPC, "Info", "Informational message");
NUI_PopupWarning(oPC, "Warning", "Warning message");
json jContent = NuiLabel(JsonString("Custom content"),
JsonInt(NUI_HALIGN_CENTER),
JsonInt(NUI_VALIGN_MIDDLE));
int nToken = NUI_DialogCreate(oPC, "Title", jContent, 1, "",
"nui_handler", NUI_PROP_CLOSABLE,
312.5f, 156.25f, FALSE);
- BioWare-style ASCII header with Carcerian art
- Title/Author/Synopsis block
- Local variable storage keys
- Forward declarations (ALL functions)
- Implementations
- EOF marker
- Functions:
NUI_PascalCase() - Constants:
NUI_CONSTANT_NAME - Local variables:
nToken,sMessage,oPC - Max filename: 16 chars (including .nss)
- No preprocessor directives (#define)
- No non-ASCII characters
- No #include cycles
- Strict forward declarations
- JSON-based configuration
- Built-in
nw_inc_nuiwidget system only
- All NuiImage calls use XML layout format
- All window functions return int (token)
- All popups use sScript="nui_handler" default
- All geometry uses NuiRect(-1.0f, Y, W, H)
const int NUI_PROP_RESIZABLE = 1; // User can resize
const int NUI_PROP_COLLAPSIBLE = 2; // User can minimize
const int NUI_PROP_CLOSABLE = 4; // X button present
const int NUI_PROP_BORDER = 8; // Visible border
const int NUI_PROP_TRANSPARENT = 16; // Transparent BG
// Predefined combinations:
const int NUI_PROP_NONE = 0;
const int NUI_PROP_CLOSABLE_ONLY = 4;
const int NUI_PROP_CLOSABLE_TRANSPARENT = 20;
const int NUI_PROP_ALL = 31;
nui_api_config.nss contains:
- Window property flags
- Default dimensions
- Color definitions
- Error codes
- AOE settings
- Logging levels
To customize:
- Edit
nui_api_config.nss - Recompile all files
- No other changes needed
All NUI events route through nui_handler.nss:
- Button clicks
- Window close events
- AOE exit events
- Custom element events
Handler automatically:
- Identifies event source
- Routes to appropriate function
- Manages window cleanup
- Logs errors
Three persistence tiers available:
nui_persist.nss- Standard persistencenui_safe_per.nss- Safety checksnui_tailor_per.nss- Tailor integration
Data stored via SetLocal* functions on player objects.
Included Files:
nui_example.nss- 10 copy-paste usage examplesNUI_ARCHITECTURE_GUIDE.txt- Deep dive into NUI internals- Comments in every function
- Clear parameter documentation
See nui_example.nss for:
- Sign display from placeable OnUsed
- Simple message popup
- Error/Success/Warning/Info popups
- Custom dialog creation
- Window positioning
- Multiple concurrent popups
- Window property customization
- Lightweight popup system (~50 KB compiled)
- No memory leaks (proper cleanup)
- Fast event routing (hash-based)
- Efficient JSON parsing
- AOE-based lifecycle management
- NWN:EE - Fully tested and compatible
- NWScript - Standard NWScript only
- Toolset - Compatible with NWN:EE toolset
- Macros - Works with macro system
- Custom UIs - Integrates with existing systems
- Portrait display requires XML layout (not direct NuiImage)
- AOE cleanup on 99999 second timer (27.7 hours)
- Single event handler per window type
- Window positions relative to screen (not world)
Window doesn't appear:
- Check module OnNUI event hook to
nui_mod_event - Verify player is PC (GetIsPC check)
- Check token > 0 on NUI_DialogCreate return
Portrait not displaying:
- Verify GetPortraitResRef returns valid resref
- Check XML layout is properly formatted
- Ensure image path is correct
AOE not working:
- Verify AOE created at sign location
- Check cleanup timer (99999 seconds)
- Confirm player is in AOE radius
Button clicks not registering:
- Check element ID is set (NuiId wrapper)
- Verify button is in jContent structure
- Confirm event handler is attached
- Use NUI_PopupMessage for simple cases
- Pool window tokens if creating many windows
- Clean up windows when done (NuiDestroy)
- Use AOE for location-based windows
- Keep JSON structures simple
Potential additions:
- Drag-and-drop support
- Custom color binding
- Grid/table layouts
- Progress bars
- Slider controls
- Text input fields
- Dropdown menus
Carcerian NUI System v1.0
Created by: Carcerian
For: Neverwinter Nights: Enhanced Edition
Last Modified: June 3, 2026
Built with strict architectural standards and comprehensive documentation. Ready for production use.
- Compiler Source: https://github.com/nwneetools/nwnsc
- NWN:EE Documentation: https://neverwintervault.org
- NUI Widget System: Built on
nw_inc_nui
This is a reference implementation. Modifications welcome but maintain:
- 7-layer file structure
- Strict forward declarations
- ASCII header format
- VERSION locked at 1.0 (use MODIFIED field)
- No non-ASCII comments
Status: ✓ v1.0 Production Ready
Compilation: ✓ All files pass NWN:EE compiler
Testing: ✓ In-game tested
Documentation: ✓ Complete