Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. {
  2. Create OMOD records for selected KYWDs
  3. }
  4. unit FO4CreateOMODforKYWD;
  5.  
  6. const
  7. sEditorID = 'modcol_ColorSwaps_%s_Primary';
  8. iTemplateOMOD = $001ADA29; // modcol_Deliverer_Scopes_Any [OMOD:001ADA29]
  9. iPlugin = 1; // plugin where to create OMODs: 0 - same plugin as keyword, 1 - the last loaded plugin
  10.  
  11.  
  12. function Process(e: IInterface): Integer;
  13. var
  14. id: string;
  15. f, tpl, omod: IInterface;
  16. begin
  17. if Signature(e) <> 'KYWD' then
  18. Exit;
  19.  
  20. if iPlugin = 0 then
  21. f := GetFile(e)
  22. else
  23. f := FileByIndex(Pred(FileCount));
  24.  
  25. id := Format(sEditorID, [EditorID(e)]);
  26.  
  27. // check if such record already exists
  28. omod := MainRecordByEditorID(GroupBySignature(f, 'OMOD'), id);
  29.  
  30. // if not found
  31. if not Assigned(omod) then begin
  32. // get template OMOD record from the game master
  33. tpl := RecordByFormID(FileByIndex(0), iTemplateOMOD, False);
  34. // copy it as a new record
  35. omod := wbCopyElementToFile(tpl, f, True, True);
  36. // set new editor id
  37. SetElementEditValues(omod, 'EDID', id);
  38.  
  39. AddMessage(Name(e) + ': Created ' + Name(omod));
  40. end else
  41. AddMessage(Name(e) + ': OMOD already exists ' + Name(omod));
  42.  
  43. end;
  44.  
  45. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement