Jump to content

Recommended Posts

Hello, I need help! I'm trying to make my character not take any penalties from eating humanmeat so I tried this to offset the penalty but if his at 20 health eating the humanmeat kills him? Is there something I can do to remove "humanmeat", "humanmeat_cooked" & "humanmeat_dried" is side effects?

inst:ListenForEvent("oneat", function(inst, data) 
if data.food.prefab == "humanmeat" then
inst.components.health:DoDelta(20)
inst.components.sanity:DoDelta(33)
end
end)

Help would be appreciated :D.

Edited by SuperDavid

This should work for the health, so keep the current code for the sanity part(remove the health line)

--modmain.lua
local humanmeats = { "humanmeat", "humanmeat_cooked", "humanmeat_dried" }

for k,v in pairs(humanmeats) do
	AddPrefabPostInit(v, function(inst)
		if not GLOBAL.TheWorld.ismastersim then return inst end
		
		inst.components.edible:SetGetHealthFn(function(inst, eater)
			if eater:HasTag("adam") then -- replace with a tag for your character
				return 0
			end
			return nil --nil will make it default to its original health value
		end)
	end)
end

 

Edited by Aquaterion

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