Jump to content

Recommended Posts

Hello, I was wondering if it's possible to make certain prefab not take penalty of faster spoilage rate when put on the ground, like is there a line of code or something to disable it like "inst.groundperishmult = nil" or something, thanks for your time :wilson_dorky:!

Edited by SuperDavid

Looking in the meats prefab for example the closest I found was:

inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST)
    inst.components.perishable:StartPerishing()

But I think there's no specific line for it being on the ground...unless I'm blind or misread...

Maybe you could try an if else statement to check if its on the ground or in the inventory, then change the TUNING.PERISH_FAST?

Hope this helps a little ^^

To actually do that, you might need to modify perishable component.

But, if you don't want to modify the component only for that one item, here's a tricky way.

Spoiler

local function ondrop(inst)

    inst.components.perishable.localPerishMultiplyer = 1/TUNING.PERISH_GROUND_MULT

end

local function onpickup(inst)

    inst.components.perishable.localPerishMultiplyer = 1

end

 

-- then in perfab fn 

    inst.components.inventoryitem:SetOnDroppedFn(ondrop)

    inst.components.inventoryitem:SetOnPutInInventoryFn(onpickup)

--

I haven't tested yet, could be buggy.:?

 

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