[Solved] How to check if a placeable is in use in a module

Hello all.

I want to check, if the model of a placeable, which is located in a hak is in use within a module (to toss out unneeded stuff).

The reference to the model is hidden in the module’s .git files as a two (four?) byte number. This number represents the line number in the placeables.2da. So a simple search for this number will probably give unrelieable results.

What I need is a report which lists all the placeables (Name, Tag) together with this number (which is called “Apperance” in NWN-Explorer).

How can such a report be generated? Is there a tool, which does the trick? Moneo maybe? (I’m no expert for moneo scripting).

Here’s a moneo script which does something very similar:

# Find all placeables which are useable. Report description for manual checking.

%mod = 'c:\NeverwinterNights\nwn\modules\Dark Energy.mod' or die;

for (%mod['*.git']) 
    $area = substr($_, 0, -4);
	%are = %mod[$area + '.are'];
    $areaname = /Name;
    close (%are);	    
	for (/{'Placeable List'}) 
        if (/~/Useable > 0)
		{print $area, ";", $areaname, ";", /~/LocName, ";", /~/Tag, ";", /~/Description, ";", "\n";}

In your case, the print line will be unconditional, and you will want to print the field Appearance.

The latter is UINT32, which you don’t need to know for this particular script.

You can change the delimiter in the output from “;” to “,” if you want a .csv file.

No doubt you’ll cross-reference the output to placeables.2da in a spreadsheet? (moneo isn’t up to doing joins AFAIK).

I guess there might also be placeable templates that you’ve set up for future use (or CreateObject scripts), in which case you need a second loop over *.utp. I can provide an example if you need it.

These days, it can also be done in nwscript, I think.

According to the Lexicon, GetAppearanceType() returns the line number in placeables.2da for placeables.

The ObjectToJson() method can also be used - overkill here, but useful if you need to work with fields that nwscript doesn’t have a specific function for.

In EE, you can cycle areas with GetFirst / NextArea(). I find it expedient to AssignCommand to each area in turn, allowing the area itself to cycle through all its objects, to avoid TMI errors.

WriteTimestampedLogEntry() can be used for the output. IIRC if you start each message with a comma, you can make a csv file, with all the timestamp waffle in the first field.

To my mind, moneo is slightly easier and more flexible - for example, with minor modification, the moneo script can be used to make permanent changes to the module, which isn’t possible with nwscript (though Json methods allow you to change things in game to some extent).

My thanks, this should work.

I’*ve overseen the “GetAppearanceType”-function which will work for placeables too; despite of the hint in the toolset, which says that it is only for creatures.

Since there’s no way to create a loop over all areas in 1.69, I’ll check out the moneo script anyway. Having a list of all “useables” will be useful at times as well.

Btw: “;” as delimiter is perfect!!! :slight_smile: :smiley:

For 1.69 there’s a workaround to get the area’s alike the EE script functions. But to get this working, you need one defined placeable set in every area. Then you would do a scan on the module load with GetObjectByTag for that placeable to index the area on a local variable and destroy this placeable in the process.

I think there was a scriptset on the vault too. Due I remember I got one from there…

Here is the include file I was using once. From two or three users, like MJ, Knat and I think another one I forgot…


Thanks, this is an excellent idea.

1 Like