Jump to content

Edible component no longer properly checks for eater


penguin0616
  • Fixed

In the latest beta update, a change was made to the edible component in Edible:GetHunger that does not properly check whether the eater exists first before doing stuff with it.

The rest of the method does do proper checks, so this change causes crashes when recruiting perms or pigmen, or in my particular case, using certain mods.

image.png.88b797236d75b8bcff0dfa7901f60809.png


Steps to Reproduce

1. Give meat to a pigman (or use a mod that calls edible:GetHunger())

2. Crash and burn

  • Like 2
  • Big Ups 1
  • Spooky 1



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

I do want to point out that while this was addressed to prevent crashing (which is good regardless, as everywhere else in the function, it was sanitized, and it's good for mods), part of the reason it crashed in the first place was that for some reason, pigs and merms don't pass themselves through the Edible:GetHunger function.

 

pigman.lua

inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER)

 

merm.lua

-- this line is also duplicated (this doesn't cause any issues though)
local loyalty_time = item.components.edible:GetHunger() * loyalty_per_hunger

 

Unlike gnarwail.lua, which does pass the inst:

inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger(inst) * TUNING.GNARWAIL.LOYALTY_PER_HUNGER)

 

If this is intended so that spoilage state (stale or spoiled) doesn't affect loyalty time for them, maybe you could add a unique parameter for them? I mean, even eater.ignoresspoilage is right there.

If not intended, then it could be addressed, other creatures pass themselves just fine for either GetHunger or GetHealth, and even pigs do so for checking GetHealth, just not for GetHunger.

  • Like 1

Share this comment


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

×
  • Create New...