Jump to content

Sanity for peting


Recommended Posts

On 11/19/2022 at 5:57 AM, imjustglue said:

trying to make a small little walter rework and i want to make so you gain a bit of sanity when petting woby, but i have no idea what var or isnt declares you can pet woby

 

I actually just did a character mod with a pet that does this! 
 

function WobyChanges(inst)	
    local function onpet(inst)
		if inst.components.follower ~= nil and inst.components.follower.leader ~= nil then
			local leader = inst.components.follower.leader
			if leader.components.sanity ~= nil then
				leader.components.sanity:DoDelta(amount)
			end
		end	
	end 
    inst:ListenForEvent("critter_onpet", onpet)	
end

^ This should handle the onpet function. I believe Woby also counts as a critter so the "critter_onpet" event handler found in SGcrittercommons should fire as well

 

AddPrefabPostInit("wobysmall", WobyChanges)

 

Edited by Mikrell
Link to comment
Share on other sites

16 hours ago, Mikrell said:

 

I actually just did a character mod with a pet that does this! 
 

function WobyChanges(inst)	
    local function onpet(inst)
		if inst.components.follower ~= nil and inst.components.follower.leader ~= nil then
			local leader = inst.components.follower.leader
			if leader.components.sanity ~= nil then
				leader.components.sanity:DoDelta(amount)
			end
		end	
	end 
    inst:ListenForEvent("critter_onpet", onpet)	
end

^ This should handle the onpet function. I believe Woby also counts as a critter so the "critter_onpet" event handler found in SGcrittercommons should fire as well

 

AddPrefabPostInit("wobysmall", WobyChanges)

 

any specific place i should put this on? like master position or do i just put it anywhere

 

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