Question about function: ActionExamine

I just wanted to ask you…I did a simple script where I wanted the “examine window”, or what you call it, to show up in game if you left click on an object, let’s say a book of some kind. This is the script:

void main()
{
object oBook = GetObjectByTag("sanctum_book_ignii");

ActionExamine(oBook);
}

Maybe I should just stick to making a NWN1 style dialog instead, but I just thought this should work. I tried with putting this script in the On Left Click slot and then I tried with the On Used slot. Neither worked. Sure, the PC could just right click on the object as usual and do examine but…

Maybe this script not working has something to do with maybe the object needs to be a character or something like that? The objects I’m using are placeables.

As always, thanks for your time!

There’s an easier way to do this. In the properties for the object, look for the “Default Action Preference” under the behavior section and change it to Examine.

Don’t know that much about scripting for NwN2 but if it’s an action doesn’t it have to be assigned to someone? In NwN you would use something like -

AssignCommand(oPC, ActionExamine(oBook));

TR

Thanks for the replies, guys! You were both right.

If I do it like you suggested Tarot_Redhand, and put it in the On Used slot, and make the script like this, it works:

void main()
{
object oPC = GetLastUsedBy();

object oBook = GetObjectByTag("sanctum_book_ignii");

AssignCommand(oPC, ActionExamine(oBook));
}

However, I did it the way travus suggested and that seems like the more appropriate way to do it. Feels like that’s the way the game intended it.

Again, thank you for your help!:slightly_smiling_face:

@andgalf There is one thing that you can do with the scripted version though assuming that the scripting in NwN 2 has the DelayCommand instruction. If you wanted a delay between the acquiring of the book and it being examined you could edit that code to look like this -

void main()
{
	object oPC = GetLastUsedBy();

	object oBook = GetObjectByTag("sanctum_book_ignii");

	DelayCommand(1.0f, AssignCommand(oPC, ActionExamine(oBook)));
}

which would give a one second delay.

On a side note (if you haven’t already seen it) this thread shows (amongst other things) how to get your code to show with the original indenting and some highlighting in these threads.

TR

assuming that the scripting in NwN 2 has the DelayCommand instruction.

@Tarot_Redhand, NWScript used by NWN2 has all the functions from NWN1 as well as some completely new ones like roster functions, FeatAdd, SetEffectSpellId, etc.

I have to make assumptions about such things because I have not made anything specifically for NwN2. While I may suspect or think I know, with my memory I aim to be on the safe side just in case I screw up (even then sometimes…).:flushed:

TR

1 Like