Sign in to follow this  
Cunning fox

Backpack finite uses.

Recommended Posts

Cunning fox    569

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

Share this post


Link to post
Share on other sites
Lumina    2149

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.

Share this post


Link to post
Share on other sites
Cunning fox    569
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

Share this post


Link to post
Share on other sites
Lumina    2149
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.

Share this post


Link to post
Share on other sites
Cunning fox    569
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

Share this post


Link to post
Share on other sites
Cunning fox    569
5 minutes ago, Lumina said:

I'll accept a reward only if all works fine, because i'm not sure this could works, i didn't test it. Thanks anyway.

It's working! Many thanks

  • Like 1

Share this post


Link to post
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
Sign in to follow this