Jump to content

I need help with sanity based light.


Recommended Posts

You'll want to take a look at rabbit.lua to see how the rabbits respond to your sanity to turn into beardlings. Specifically the WatchSanity function that gets called by OnPickup. You'll probably want to call WatchSanity in an OnEquip function and StopWatchingSanity in OnUnequip.

Link to comment
Share on other sites

I think you would put something like this in YOURCHARACTER.lua inside the master_postinit ;)~

inst:ListenForEvent("sanitydelta", function(inst, data)
   if inst.components.sanity.current >= 150 then
      -- Set max light level
   elseif inst.components.sanity.current >= 100 then
      -- Lower light level
   elseif inst.components.sanity.current >= 50 then
      -- Lower light level
   elseif inst.components.sanity.current <= 50 then
      -- Set min light level
   end
end)

 

Link to comment
Share on other sites

On 2/5/2017 at 10:31 PM, SuperDavid said:

I think you would put something like this in YOURCHARACTER.lua inside the master_postinit ;)~


inst:ListenForEvent("sanitydelta", function(inst, data)
   if inst.components.sanity.current >= 150 then
      -- Set max light level
   elseif inst.components.sanity.current >= 100 then
      -- Lower light level
   elseif inst.components.sanity.current >= 50 then
      -- Lower light level
   elseif inst.components.sanity.current <= 50 then
      -- Set min light level
   end
end)

 

This ought to work, you can alternatively call an outside function which is basically the same method.

 

local function sanitylight(inst)
	if inst.components.sanity.current >= 150 then
		inst.Light:SetIntensity(0.5)
		inst.Light:SetRadius(0.9)
		inst.Light:SetFalloff(0.5)
	elseif inst.components.sanity.current >= 100 then
      -- Lower light level
		inst.Light:SetIntensity(0.5)
		inst.Light:SetRadius(0.9)
		inst.Light:SetFalloff(0.5)
	elseif inst.components.sanity.current >= 50 then
      -- Lower light level
		inst.Light:SetIntensity(0.5)
		inst.Light:SetRadius(0.9)
		inst.Light:SetFalloff(0.5)
	elseif inst.components.sanity.current <= 50 then
      -- Set min light level
		inst.Light:SetIntensity(0.5)
		inst.Light:SetRadius(0.9)
		inst.Light:SetFalloff(0.5)
	end
end
                                              
--Put this part in Master Post Init
inst:ListenForEvent("sanitydelta", sanitylight)

Then just change the light settings to whatever you want for each stage like SuperDavid mentioned.

Link to comment
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
 Share

×
  • Create New...