Jump to content

Recommended Posts

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.

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...