yamgo Posted June 27, 2018 Share Posted June 27, 2018 I'm trying to create a personal mod to make Woodies axe Lucy equippable on other characters (Wendy in this case). I know it works if I just change the IsValidOwner function in possessedaxe.lua, but I don't want to directly edit game prefabs. How can I overwrite the function in modmain.lua? I tried: AddPrefabPostInit("possessedaxe", function(inst) local function IsValidOwner(inst, owner) return owner:HasTag("ghostlyfriend") end end) but it doesn't do anything. Any help would be appreciated. Link to comment Share on other sites More sharing options...
DarkMatterZero Posted June 27, 2018 Share Posted June 27, 2018 If I remember correctly, "possessedaxe" is a component, not a prefab. That is to say, you need to use "AddComponentPostInit" instead of "AddPrefabPostInit". Additionally, I think there's an extra bit of code involved in overwriting an existing function. I think in the past I've seen people write the code something like this: AddComponentPostInit("possessedaxe", function(self, inst) local old_IsValidOwner = self.IsValidOwner self.IsValidOwner = function(inst, owner) return owner:HasTag("ghostlyfriend") end end) Hope this helps! Link to comment Share on other sites More sharing options...
yamgo Posted June 29, 2018 Author Share Posted June 29, 2018 Thanks for the help! Sadly it doesn't seem to work, Lucy is still slipping out of my hands. Since it's a personal mod however, I'm just gonna stick to overwriting the possessedaxe component for now. 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