Cunning fox Posted December 29, 2016 Share Posted December 29, 2016 Hey all! I'm trying to edit prefab so it will work with my mod. Is it posible to somehow eddit some functions and add some components to prefab without re-adding it? If someoe'll help me, I'll give him some skins such as: Tuxedo Gloves Green Sweater Vest Knee Pants Blue Sneakers 1 Link to comment Share on other sites More sharing options...
CarlZalph Posted December 29, 2016 Share Posted December 29, 2016 Without much information this is as generic as I can make it. AddPrefabPostInit( "someprefabname", function(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("somecomponentname") end local somefunction_old = inst.somefunction if somefunction_old then inst.somefunction = function(self, arg1, arg2, ...) -- Prehook here somefunction_old(self, arg1, arg2, ...) -- Posthook here end end end ) Link to comment Share on other sites More sharing options...
Cunning fox Posted December 29, 2016 Author Share Posted December 29, 2016 7 hours ago, CarlZalph said: Without much information this is as generic as I can make it. AddPrefabPostInit( "someprefabname", function(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("somecomponentname") end local somefunction_old = inst.somefunction if somefunction_old then inst.somefunction = function(self, arg1, arg2, ...) -- Prehook here somefunction_old(self, arg1, arg2, ...) -- Posthook here end end end ) What is _old for? I need to add it to the name of my function? 1 Link to comment Share on other sites More sharing options...
PanAzej Posted December 29, 2016 Share Posted December 29, 2016 (edited) 24 minutes ago, makar5000 said: What is _old for? I need to add it to the name of my function? "Somefunction_old" is an example name of a variable you can use to store old version of the function, before you replaced it with a new, custom one. It allows you to use the old function when needed. Edited December 29, 2016 by PanAzej words Link to comment Share on other sites More sharing options...
Cunning fox Posted December 30, 2016 Author Share Posted December 30, 2016 22 hours ago, CarlZalph said: Without much information this is as generic as I can make it. AddPrefabPostInit( "someprefabname", function(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("somecomponentname") end local somefunction_old = inst.somefunction if somefunction_old then inst.somefunction = function(self, arg1, arg2, ...) -- Prehook here somefunction_old(self, arg1, arg2, ...) -- Posthook here end end end ) Ok, thx. Give me youre trade link, so I can give you your reward 1 Link to comment Share on other sites More sharing options...
CarlZalph Posted December 30, 2016 Share Posted December 30, 2016 Just now, makar5000 said: Ok, thx. Give me youre trade link, so I can give you your reward Ah keep your items, matey. I try to help those I see askin' for it. Link to comment 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