Zorkaz Posted December 5, 2020 Share Posted December 5, 2020 Is there a "comfortable" way of determining what components a misc item is made of when using a script? E.g. when fueling a motor with a gas canister, the steel is returned to the player Link to comment Share on other sites More sharing options...
SKKmods Posted December 5, 2020 Share Posted December 5, 2020 If you dont know what components arbitrary MISC junk items are made of, then the fastest way I found for my auto junk scrapping solutions is to move the MISC junk item(s) from the source inventory to a discrete container and then cycle through a formlist of 30 base CMPO components using GetComponentCount() adding the resulting count of MISC scrap items back to the source inventory. The two form lists need to have the same index order of CMPO:MISC items. Formlist Property pSKK_ScrapperMISCList Auto ;30 MISC junk components Formlist Property pSKK_ScrapperCMPOList Auto ;30 CMPO junk components SourceREF.RemoveItem(ThisMISCJunkItem, aiCount = 1, abSilent = true, akOtherContainer = TempContainerREF) Int iIndex = 0 While (iIndex < pSKK_ScrapperCMPOList.GetSize()) Int iScrapCount = TempContainerREF.GetComponentCount(pSKK_ScrapperCMPOList.GetAt(iIndex)) SourceREF.AddItem(pSKK_ScrapperMISCList.GetAt(iIndex), iScrapCount, true) iIndex += 1 Endwhile ps If you already know what componets a specific MISC junk item is made of, just remove the item add the components to the inventory. Link to comment Share on other sites More sharing options...
DieFeM Posted December 5, 2020 Share Posted December 5, 2020 (edited) E.g. when fueling a motor with a gas canister, the steel is returned to the player I think that RemoveComponents is what you are looking for. Removes a certain count of a specified component from the container's inventory, scrapping objects as necessary, and returning the change to the container.Function RemoveComponents(Component akComponent, int aiCount, bool abSilent = false) native I would use a combination of OnItemAdded for the event (once you add the gas canister to the motor container) that uses GetComponentCount as condition (to check for items that have oil component) and use RemoveComponets on the ones that meet the condition (to remove the oil and return the change to the container). Edited December 5, 2020 by DieFeM Link to comment Share on other sites More sharing options...
Zorkaz Posted December 5, 2020 Author Share Posted December 5, 2020 Thank you both Link to comment Share on other sites More sharing options...
Recommended Posts