kavaline Posted October 28, 2016 Share Posted October 28, 2016 I try this code in my modmain.lua: if GLOBAL.TheNet:GetIsServer() then local Prefabs = GLOBAL.Prefabs for k, v in pairs(Prefabs) do AddPrefabPostInit(v, function(inst) if not inst.components.tradable and inst.components.equippable ~= nil then inst:AddComponent("tradable") end end) end end But when I enter in the game, nothing happens... I'm done something wrong, or i can do it in other way? (my objective is add the component Tradable for all equippable itens (armors, tools, weapons, amulets, etc) Link to comment https://forums.kleientertainment.com/forums/topic/71215-help-add-component-for-a-large-number-of-prefabs/ Share on other sites More sharing options...
Serpens Posted October 28, 2016 Share Posted October 28, 2016 if you want to add to every prefab something, use AddPrefabPostInitAny(function(inst) ... end) Link to comment https://forums.kleientertainment.com/forums/topic/71215-help-add-component-for-a-large-number-of-prefabs/#findComment-830461 Share on other sites More sharing options...
kavaline Posted October 28, 2016 Author Share Posted October 28, 2016 Works perfectly! Thanks =D Link to comment https://forums.kleientertainment.com/forums/topic/71215-help-add-component-for-a-large-number-of-prefabs/#findComment-830506 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now