Jump to content

Backpack finite uses.


Recommended Posts

I'm trying to set to backpack finite uses. I'm adding 

inst:AddComponent("fueled")
inst.components.fueled.fueltype = FUELTYPE.USAGE
inst.components.fueled:InitializeFuelLevel(TUNING.TOPHAT_PERISHTIME)
inst.components.fueled:SetDepletedFn(--[[generic_perish]]inst.Remove)

It's not working. Backpack shows 100 percents, but the number doesn't changes.

If someone'll give me help, i'll give him some skins: Buckled Backpack and Silk robe!

 

  • Like 1
Link to comment
Share on other sites

When you equip a fueled item, in the "onequip" function, you have :


        if inst.components.fueled ~= nil then
            inst.components.fueled:StartConsuming()
        end

In the "onunequip" function, you have :


        if inst.components.fueled ~= nil then
            inst.components.fueled:StopConsuming()
        end

Also, i'm not sure that when the backpack is destroyed (no more fuel) the backpack will drop the item, so you probably need to custom the "SetDepletedFn", but this part is beyond my skill.

Link to comment
Share on other sites

14 minutes ago, Lumina said:

When you equip a fueled item, in the "onequip" function, you have :



        if inst.components.fueled ~= nil then
            inst.components.fueled:StartConsuming()
        end

In the "onunequip" function, you have :



        if inst.components.fueled ~= nil then
            inst.components.fueled:StopConsuming()
        end

Also, i'm not sure that when the backpack is destroyed (no more fuel) the backpack will drop the item, so you probably need to custom the "SetDepletedFn", but this part is beyond my skill.

Like in this mod?

  • Like 1
Link to comment
Share on other sites

1 minute ago, makar5000 said:

Like in this mod?

Kinda, but drop everything when depleted rather than when picked up.

 


local function onburnt(inst)
    if inst.components.container ~= nil then
        inst.components.container:DropEverything()
        inst.components.container:Close()
        inst:RemoveComponent("container")
    end

    SpawnPrefab("ash").Transform:SetPosition(inst.Transform:GetWorldPosition())

    inst:Remove()
end

Something like this function, i think, but maybe you first have to drop it, then drop everything then remove it.

Link to comment
Share on other sites

Just now, Lumina said:

Kinda, but drop everything when depleted rather than when picked up.

 



local function onburnt(inst)
    if inst.components.container ~= nil then
        inst.components.container:DropEverything()
        inst.components.container:Close()
        inst:RemoveComponent("container")
    end

    SpawnPrefab("ash").Transform:SetPosition(inst.Transform:GetWorldPosition())

    inst:Remove()
end

Something like this function, i think, but maybe you first have to drop it, then drop everything then remove it.

Thanks! Give me your trade link, so I can give you your reward.

  • Like 1
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...