Script that shows specific picture with keybind

Could someone write me a script that would display picture called pause.tga when pressing space bar and turn picture off when pressing it again? What I’m trying to do is something simillar to NWN1 when game was paused character portrait changed to different picture that indicated that game is paused. Also as far as I understand this script should somehow be called out through xml file that specifies a place where this picture shows up right?

when Pause is pressed, the paused.xml gui is shown … (i think, am not testing anything atm)

perhaps paused.xml could be adapted to run a script that changes the portrait(s)


then when paused.xml unloads, the portrait could be changed back to normal

Or the partybar.xml gui (the party-portraits on the right of the screen) could be adapted, and a script that fires via paused.xml could change the portrait elements to pause.tga

just ideas, it would take a fair bit of shenanigans just to find out if it can work,

This is the script that fires up when pressing space in game which shows the text “Game Paused”:


Unfortunately I don’t have idea where scripts are located not to even mention rewriting them.

I don’t know much about xml coding unfortunately, but @Lance_Botelle seems quite knowledgable about this. Maybe you could take a look at his tutorials:

1 Like

I’ve also checked the partybar.xml file, there are 4 frame states that are responsible for indicating if character is dead, dying, ready to levelup or if it is a leader of the party and I’ve tried to add 5th that would switch portrait to pause graphic but it didn’t worked. Either there is no script to do this or I don’t know it’s exact name so the game isn’t getting the correct code. This is how it looks like:

		<UIIcon name="PORTRAIT_FRAME_PAUSED"	x=119 y=0 width=78 height=122 img="p_m_pause.tga"	hidden=true ignoreevents=true 
		update=true OnUpdate=UIObject_OnUpdate_CheckForPauseNotification() draggable=false />

I’m almost certain that the part OnUpdate is wrong since it was my own writting and so far I’ve tried: CheckForPauseNotification

that’s not a script. It’s a hardcoded gui function …

am gonna try to overlay a graphic on the partybar element that shows the portraits …

thats sorta the right idea, but I think that a script needs to show/hide that element, concealing the regular portrait if/when enabled …

testing req’d


If I recall correctly, I believe it’s actually the noticewindow.xml you would need to edit.

That would call a script that altered the portrait defined in the partybar.xml.

Note, the noticewindow.xml fires rapidly and so you would need to ensure it does not crash the system with any script calls you make from it … especially if considering MP coding. i.e. Control it via the HOST only when checking.

Here is my own edited version which I use for something I do … It may give you a starting point, but recognise it is simply something I use in my own campaign to help control my turn-based combat system that works with the pause.

<?xml version="1.0" encoding="utf-8"?>
<!-- Neverwinter Nights 2                     -->
<!-- Copyright � Obsidian Entertainment, Inc. -->

<UIScene name="SCREEN_NOTICEWINDOW" x=0 y=0 width="SCREEN_WIDTH" height="SCREEN_HEIGHT" 
         capturemouseevents=false capturemouseclicks=false ignoreevents="true"
         scriptloadable="true" priority="SCENE_SCRIPT" fullscreen="true" />

	<UIText name="NOTICE_TEXT" x=ALIGN_CENTER y=68 width=800 height=200 fontfamily="Special_Font" style="2" multiline=true maxlines=3
	        align=center valign=top uppercase=true hidden=true update=true ignoreevents="true" 
	        capturemouseevents=false capturemouseclicks=false color="yellow" scalewithscene=true
	        OnUpdate=UIText_OnUpdate_DisplayNoticeText(3.0,5.0) />

	<UIText name="PAUSE_NOTIFICATION" x=0 y=ALIGN_CENTER width=1024 height=100 fontfamily="Special_Font" style="4" scalewithscene=true 
		align=center valign=middle uppercase=true text="Game Paused" hidden=true ignoreevents="true"
        capturemouseevents=false capturemouseclicks=false
		update=true updaterate="0.1" OnUpdate=UIText_OnUpdate_ShowPauseNotification() OnUpdate0=UIObject_MISC_ExecuteServerScript("gui_updatetargets","TESTUNPAUSED")/>

As @kevL_s says, it can be quite involved.

Again, if I recall correctly, I had some difficulty here when I was trying to add an overlay to show AI working on the portraits. Remember (when we looked at something like this before) that in the end I went for the small AI icon next to the portrait instead. So if you do manage to get this to work, I would be interested. :slight_smile:



from <install>Nwn2/UI/default
to <documents>Nwn2/ui/custom

Add this line to UIListBox name="PARTY_LIST"


and add the following lines below


<!-- kL_add Show an alternate icon when paused -->
<UIIcon name="PORTRAIT_BG_PAUSED" x="119" y="0" width="78" height="86" img="p_m_dead2.tga"
hidden="true" ignoreevents="true" draggable="false" />

NOTE: I used p_m_dead2.tga as an example graphic – change it to the picture you want, put it in /override or /ui or somewhere accessible to the engine, and make sure its dimensions and outline match that of p_m_dead2.tga

Then create this script in <documents>Nwn2/override

(create a subfolder “Gui_Paused” or similar)

Call it gui_paused.nss and compile it :

// 'gui_paused'
    Gui script for partybar.xml
    Hides the portrait if the game is paused and shows an alternate icon instead.

    note: Hiding "CUSTOM_PORTRAIT_ICON" doesn't appear to be needed but hey.

void main()
    object oSelf = OBJECT_SELF;

    int bPaused = GetPause();

    SetGUIObjectHidden(oSelf, "SCREEN_PARTY_BAR", "PORTRAIT_BG", bPaused);
    SetGUIObjectHidden(oSelf, "SCREEN_PARTY_BAR", "CUSTOM_PORTRAIT_ICON", bPaused);

    SetGUIObjectHidden(oSelf, "SCREEN_PARTY_BAR", "PORTRAIT_BG_PAUSED", !bPaused);

on my setup, only the PC’s portrait changed (despite the UIPane being prototyped…). This is actually a good thing since the Companions are still showing their portraits for item-transfers, take control, etc while paused.

technote: It might be better to fire the change from paused.xml since then OnUpdate0 wouldn’t be need to fire repeatedly in partybar.xml … regardless, i expect you’ll have to tweak stuff like the x/y values etc.

1 Like

hey Lance,

I haven’t looked into SCREEN_NOTICEWINDOW but i bypass the Game Paused notice in the center of the screen like this


<?xml version="1.0" encoding="utf-8"?>

<UIScene name="SCREEN_PAUSED" width="900" height="100" x="ALIGN_CENTER" y="ALIGN_CENTER" minwidth="800" minheight="100" priority="SCENE_INGAME"
capturemouseevents="false" capturemouseclicks="false" ignoreevents="true" focusable="false" draggable="false" />

	<UIText name="PAUSE_NOTIFICATION" x="0" y="ALIGN_CENTER" width="PARENT_WIDTH" height="PARENT_HEIGHT" fontfamily="Special_Font" style="4"
	align="center" valign="middle" uppercase="true" strref="174270" hidden="true" scalewithscene="true"
	capturemouseevents="false" capturemouseclicks="false" ignoreevents="true" focusable="false" draggable="false"
	update="true" OnUpdate='UIText_OnUpdate_ShowPauseNotification()' />

[edit] on looking yes I also do this


<?xml version="1.0" encoding="utf-8"?>
<!-- Neverwinter Nights 2					  -->
<!-- Copyright � Obsidian Entertainment, Inc. -->

<UIScene name="SCREEN_NOTICEWINDOW" x="0" y="0" width="SCREEN_WIDTH" height="SCREEN_HEIGHT"
capturemouseevents="false" capturemouseclicks="false" ignoreevents="true"
scriptloadable="true" priority="SCENE_SCRIPT" fullscreen="true" />

	<UIText name="NOTICE_TEXT" x="ALIGN_CENTER" y="168" width="800" height="200"
	fontfamily="Special_Font" style="2" multiline="true" maxlines="3" color="yellow"
	align="center" valign="top" uppercase="true" hidden="true" scalewithscene="true"
	ignoreevents="true" capturemouseevents="false" capturemouseclicks="false"
	update="true" OnUpdate='UIText_OnUpdate_DisplayNoticeText(15.0,5.0)' />

	<UIText name="PAUSE_NOTIFICATION" x="0" y="ALIGN_CENTER" width="1024" height="100" fontfamily="Special_Font" style="4" scalewithscene="true"
	align="center" valign="middle" uppercase="true" strref="174270" hidden="true" ignoreevents="true"
	capturemouseevents="false" capturemouseclicks="false"
	update="true" OnUpdate='UIText_OnUpdate_ShowPauseNotification()' />
1 Like


Ah! Going through your posts, I think I was aiming at something slightly different from using just the pause.xml. I needed to monitor “while paused”, which may have been why I thought of the noticewindow.xml. That may also explain a few of my other points too. Although, I still don’t remember all the details why I could not simply overlay the “AI” on the portraits … oh well, not to worry and it sounds like the OP is on the right track now. :slight_smile:

EDIT: OK, I found the issue I was meaning from the time … I don’t think applying an AI overlay would have been as practical in the circumstances, as it was required to work with other overlays.

1 Like

One thing about this that I would like, if it’s not too complicated, is to get the “Game Paused” text even when you’re not in cutscene/NWN2 dialogue mode. If you’re not in cutscene/NWN2 dialogue mode it just says “Paused” in the chat window. To do the changing of portrait stuff is not for me, but this thing would actually be an improvement to the game, I think. Would that be easy to do?

I tried to read your tutorial, Lance, but after about 9 pages I gave up. Unless I have something I really need xml wise, I will pass on learning the whole thing for the time being. At first it felt easy when you explained it, but the longer I got into the text, the more involved it became.

NWN2 has a default text “Game Paused” in the middle of the screen (not sure if this is exactly what you’ve meant) but it was removed with Tchos’ HD UI if you are using it just remove file called noticewindow.xml from your override folder and it should show up again.

Thank you very much! Script is working as intended and I wouldn’t be able to do it without help;)

Edit: I’ve managed to fire script from noticewindow.xml instead of paused.xml (my guess is that the second one is responsible for text displayed during cutscenes and conversations). Also it is better to put


above all frame states so the graphic will cover death state and levelup marker.
Also any idea why picture is showing only on PC character and not companions?

1 Like

Oh, I didn’t realize that. I am indeed using Tchos’ HD UI. Thanks @mhroczyn ! :slight_smile:

Hi @andgalf,

The tutorial is more of a guide to get someone started. i.e. You have your goal (see your quotes) … now it’s a case of interpreting what are of the xml code you need to address. If you have a basic grasp, it may help you know where to start. That’s one goal of the tutorial. After that, it is very much an experimental exercise to achieve something you want to do with GUIs.

Importantly, I would add that xml coding for me is no sure thing either. Like you, I would have to experiment with what I am trying to do. It’s not the same as doing stuff with scripts. :innocent:

That all said, it looks like you have your answer now.

Just bear in mind that XML coding is more difficult (in my opinion anyway). EDIT: I still refer to my own tutorial. :slight_smile:

1 Like

Hi @mhroczyn,

I think that was my experience also and why I recommended looking there too.

Its probably because the pause is main pc related only with respect to GUI feedback. I think this related to my own experience and another reason I went icon instead (for what IU needed).

1 Like

Well, if XML coding is more difficult than normal scripting, I think it’s not for me. I’m too dumb for that, as I find scripting quite difficult still. :grinning:

1 Like

really don’t know. Each character’s portrait etc. is inside <UIPane name="CHAR_BOX" prototype="true"> which should mean all that inner stuff gets repeated per character. [note that prototype=true for UIPortrait name="PORTRAIT_BG" doesn’t appear to do anything – i removed it and didn’t notice any difference] so, as far as my understanding goes the custom graphic ought to be repeating also … but am glad it doesn’t :)