Jump to content

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
https://forums.kleientertainment.com/forums/topic/71712-backpack-finite-uses/
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.

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

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
41 minutes ago, makar5000 said:

It's working! Many thanks

https://steamcommunity.com/tradeoffer/new/?partner=92615579&token=Qun13WpY

Then i guess this is the trade url if you really want to offer me something. :) (First time i do this so not sure it's that :D )

3 minutes ago, Lumina said:

https://steamcommunity.com/tradeoffer/new/?partner=92615579&token=Qun13WpY

Then i guess this is the trade url if you really want to offer me something. :) (First time i do this so not sure it's that :D )

You need to open your inventory

  • Like 1

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