Jump to content

Photo

How can I automatize keywords adding

keyword software

  • Please log in to reply
6 replies to this topic

#1
alexalexalex11314

alexalexalex11314

    Journeyman

  • Members
  • Pip
  • 28 posts

Special Edition only

 

Is there any software or CK-function or something which could help me with adding kewords to some items?

For Ex, if there is an item and it has two keywords: ArmorGauntlets and ArmorHeavy, can I add my own keyword somehow to ALL the items with those keywords at one time?

 

 

I really don't want to add keywords all night long, especially one item by one. And another night again, one by one, if something changes.

 

As I understand, there is a similar function in SSE edit, but I'm not shure and couldn't figure it out how it works. Is there is something like that you know, tell me please.



#2
SeraphimKensai

SeraphimKensai

    Have you all seen my keys? I think they are here somewhere.

  • Members
  • PipPipPip
  • 560 posts

There might be a way via adding a script that fires from a quest that is hidden that runs once at the beginning of the game and applies the keyword to any item with the qualifying keyword, which if that's possible would work with mods that include items using your qualifying keyword. check www.creationkit.com for some tutorials if you need.

 

Mind you, that means in CK the items won't have your keyword, but in game it gets added while the game is running.



#3
alexalexalex11314

alexalexalex11314

    Journeyman

  • Members
  • Pip
  • 28 posts

That's a good idea, thank you, I'm gonna try it.



#4
alexalexalex11314

alexalexalex11314

    Journeyman

  • Members
  • Pip
  • 28 posts

And the first problem, what papyrus function should I use to check all the needed items?
I'm confused, have no idea what an algorithm there should be to check the items and to add the keywors...



#5
LordWabbit2

LordWabbit2

    Stranger

  • Members
  • Pip
  • 5 posts

Keywords can't be added via script, they can only be added via CK and they are immutable.  There is a workaround where you can create a form list with your keyword and then use script to add the form list, not sure if that would work in your situation.

I am also looking for a way to add a keyword (or two) two a whole slew of Armor items, to do it manually is... well, not gonna happen, I want to play Skyrim not Creation Kit.  

You can add a Keyword via SSEEdit which would be faster than using the CK (even with the CK optimisations) but it's still means doing each item one at a time.  

I'm looking for a way to script it in SSEEdit, will post an update if I find a solution.



#6
LordWabbit2

LordWabbit2

    Stranger

  • Members
  • Pip
  • 5 posts

Well that was easier than I thought, took a while to figure out Pascal again, it's been a long time since I coded with that.

There is already a script to add keywords in SEEdit, it adds keywords to weapons though, so a bit of tweaking is required.

Then all you need to do is select the armor you want to change (you can shift click to select more than one) and then apply script.

At the top you need to edit this line to add the formid of the keyword you want to add.

slKeywords.Add('0006BBE8');

The only other change is the filter on signature

if Signature(e) <> 'WEAP' then

needs to change to 

if Signature(e) <> 'ARMO' then

Although the filter is only needed if you apply the script to an entire esm instead of just selecting the items you want.

 

I have included the script in case you don't have it in your SEEdit for some reason.

{
  This script will add keywords to the keywords list of selected armor.
  Almost no practical use, just a demo.
}
unit UserScript;

var
  slKeywords: TStringList;

function Initialize: integer;
begin
  // keywords to add
  slKeywords := TStringList.Create;
  slKeywords.Add('0006BBE8'); // ArmorClothing [KYWD:0006BBE8]
  //slKeywords.Add('0008F958'); // VendorItemWeapon
  // instead can also load keywords from a text file (one keyword per line)
  // ProgramPath - path were xEdit exe file is
  // DataPath    - path to game's Data folder
  // slKeywords.LoadFromFile(ProgramPath + 'keywords.txt');
end;
    
function Process(e: IInterface): integer;
var
  kwda, k: IInterface;
  i, j: integer;
  exists: boolean;
begin
  Result := 0;

  // apply only to weapons
  if Signature(e) <> 'ARMO' then
    Exit;

  // get existing keywords list or add a new
  kwda := ElementBySignature(e, 'KWDA');
  if not Assigned(kwda) then
    kwda := Add(e, 'KWDA', True);
    
  // no keywords subrecord (it must exist) - terminate script
  if not Assigned(kwda) then begin
    AddMessage('No keywords subrecord in ' + Name(e));
    Result := 1;
    Exit;
  end;

  // iterate through additional keywords
  for i := 0 to slKeywords.Count - 1 do begin
  
    // check if our keyword already exists
    exists := false;
    for j := 0 to ElementCount(kwda) - 1 do
      if IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = slKeywords[i] then begin
        exists := true;
        Break;
      end;
    
    // skip the rest of code in loop if keyword exists
    if exists then Continue;
    
    // CK likes to save empty KWDA with only a single NULL form, use it if so
    if (ElementCount(kwda) = 1) and (GetNativeValue(ElementByIndex(kwda, 0)) = 0) then
      SetEditValue(ElementByIndex(kwda, 0), slKeywords[i])
    else begin
      // add a new keyword at the end of list
      // container, index, element, aOnlySK
      k := ElementAssign(kwda, HighInteger, nil, False);
      if not Assigned(k) then begin
        AddMessage('Can''t add keyword to ' + Name(e));
        Exit;
      end;
      SetEditValue(k, slKeywords[i]);
    end;
  
  end;
  
  // update KSIZ keywords count
  if not ElementExists(e, 'KSIZ') then
    Add(e, 'KSIZ', True);
  SetElementNativeValues(e, 'KSIZ', ElementCount(kwda));
  
  AddMessage('Processed: ' + Name(e));

end;

function Finalize: integer;
begin
  slKeywords.Free;
end;

end.

Despite the original authors comment about it not having any practical purposes it turns out it did, at least for me.


Edited by LordWabbit2, 29 May 2020 - 12:17 PM.


#7
wakenblake88

wakenblake88

    Stranger

  • Premium Member
  • 1 posts

Well that was easier than I thought, took a while to figure out Pascal again, it's been a long time since I coded with that.

There is already a script to add keywords in SEEdit, it adds keywords to weapons though, so a bit of tweaking is required.

Then all you need to do is select the armor you want to change (you can shift click to select more than one) and then apply script.

 

By the gawds, thank you. This was exactly what I've been looking for. 







Also tagged with one or more of these keywords: keyword, software

Page loaded in: 1.403 seconds