Jump to content

Recommended Posts

Trying to modify a function in the torch prefab.

AddPrefabPostInit("torch", function(self)
	print("I have spawned")
	local og_fueleffect = self.getskillfueleffectmodifier
	self.getskillfueleffectmodifier = function(self, skilltreeupdater) 
		print("Initiating Pre-hook")
		local ret = og_fueleffect(self, skilltreeupdater)
		print("Activating Posthook")
		return ret
	end
end)

The first print happens everytime a torch is spawned in, but everything else doesn't work. The hook isn't printing to the console and no code I put in it ever gets run. Other working mods do the same thing, like this mod for Wilson.

AddComponentPostInit("beard", function(Beard)

	local original_EnableGrowth = Beard.EnableGrowth
	Beard.EnableGrowth = function(self, enable)
		if self.inst.prefab == 'wilson' then
			---- do nothing
		else
			original_EnableGrowth(self, enable)
		end
	 end

I don't see how what I'm doing is any different...

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...