-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApply Material Swap.pas
More file actions
33 lines (25 loc) · 1.03 KB
/
Apply Material Swap.pas
File metadata and controls
33 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
Applies material swaps from the base object to placed references. Run this on a cell.
See https://forums.nexusmods.com/index.php?/topic/6992141-custom-material-swapping-problem/
}
unit ApplyMatSwap;
function Process(e: IInterface): integer;
var
baseForm, baseMatSwap, refMatSwap: IInterface;
begin
Result := 0;
if (Signature(e) <> 'REFR') then begin
exit;
end;
baseForm := LinksTo(ElementBySignature(e, 'NAME'));
if (Signature(baseForm) <> 'STAT') and (Signature(baseForm) <> 'SCOL') then begin
exit
end;
baseMatSwap := LinksTo(ElementByPath(baseForm, 'Model\MODS'));
refMatSwap := LinksTo(ElementByPath(e, 'XMSP'));
if ((assigned(baseMatSwap)) and (not assigned(refMatSwap))) then begin
AddMessage('Doing '+FullPath(e));
SetElementEditValues(e, 'XMSP', IntToHex(GetLoadOrderFormID(baseMatSwap), 8));
end;
end;
end.