Sign in to follow this  
Feanara

Sanity loss when starting fires?

Recommended Posts

Feanara    0

I want my custom character to lose sanity every time they light a fire (excluding adding fuel to a firepit or crafting a torch). But the fire mechanic is confusing me.

I thought it would be simple, just adding the line inst.components.lighter:SetOnLightFn(firefn). But I guess characters don't have the 'lighter' component, instead that goes into the torch itself. 

How do I detect when my character lights something on fire using a torch?

Share this post


Link to post
Share on other sites
penguin0616    5

I would suggest you take a look at the component "Lighter". Whenever you light something with a lighter, it calls :Light() (excluding whacking stuff with a torch)

You could replace the Lighter function to have a concrete indicator of when you light something.

An example:

AddComponentPostInit("lighter", function(self)
	local oldLight = self.Light
	
	function self:Light(...)
		print("oh hey I lit something on fire")
		-- deduct sanity here
		
		return oldLight(self, ...)
	end
end)

 

Edited by penguin0616
  • Like 1

Share this post


Link to post
Share on other sites

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
Sign in to follow this