hubbawubba Posted November 28, 2017 Share Posted November 28, 2017 Hi, so I am still on my quest to familiarize myself with skyrim modding. I want to add an item(armor) from another mod to the player's bag and then equip it. I know I should be using: Game.GetPlayer().AddItem()Game.GetPlayer().EquipItem() Though, from what I can gather they require you to add the armor within an ESP which I do not want. There is also the option of using Game.GetForm but I do not even know how to equip the item after getting it. What I prefer is a way to get the item by name then equip it. I also want to know if it is possible to check if there is an instance of the item before adding it to the bags, if that is the case, equip the item already available. Thanks for your time. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 28, 2017 Share Posted November 28, 2017 Let us see if I got this right. You have an item from Mod A that you want to add and equip in your mod (Mod B) Option #1Make the plugin of Mod A a parent master of your mod, Mod B. Start off by 'esmify-ing' the Mod A plugin with Wrye Bash (right click on plugin and choose 'esmify' Check mark it in the Creation Kit with your Mod B plugin set to be the active plugin. Apply the following lines to your script (or script fragment): Armor Property ModA_Armor Auto ;change the ModA_Armor variable name to the Editor ID name of the armor in question and use Auto-fill in the property window to assign the correct data ;the following lines are to be inside of a function or event Actor PlayerRef = Game.GetPlayer() If PlayerRef.GetItemCount(ModA_Armor) <= 0 PlayerRef.AddItem(ModA_Armor,1) EndIf PlayerRef.EquipItem(ModA_Armor) Fill the propertes Save your plugin Use Wrye Bash to "espfiy" the Mod A plugin Test in game Option #2Use GetFormFromFile and skip messing with the Mod A plugin Simply apply the following in your script: ;everything here needs to go inside a function or event ;replace ZZZZZZ with the last 6 digits of the objects Editor ID number Armor ModA_Armor = Game.GetFormFromFile(0x00ZZZZZZ,"ModA_PluginName.esp") Actor PlayerRef = Game.GetPlayer() If ModA_Armor ;just a check to ensure we retrieved a valid object -- allows Mod B to work even without Mod A present If PlayerRef.GetItemCount(ModA_Armor) <= 0 PlayerRef.AddItem(ModA_Armor,1) EndIf PlayerRef.EquipItem(ModA_Armor) EndIf Save your plugin Test in gamePersonally, I prefer option #2. There is less room for error, it can work (or at least quietly fail) even if the user did not install Mod A. Whereas with option #1, the user must have Mod A installed or their game will CTD at the main menu. Link to comment Share on other sites More sharing options...
hubbawubba Posted November 28, 2017 Author Share Posted November 28, 2017 Thanks a lot for the information, IsharaMeradin. I decided to go with the second one for simplicity. The code is pretty clear, it is much appreciated. Though, I had a compiling issue until I added "Game.GetFormFromFile(0x00ZZZZZZ,"ModA_PluginName.esp") as armor". Everything is working nicely. Thanks again. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 28, 2017 Share Posted November 28, 2017 Sorry, mistakes happen. Glad you caught it and got it working for your needs. Link to comment Share on other sites More sharing options...
Recommended Posts