Jump to content

Recommended Posts

Im trying to find a way to make it so if my custom item drops,the item is removed. 
Im honestly just trying to find a work around for when a custom item is dropped into water, it get removed, but i think the above way may give me hints as to how to do that.

3 hours ago, CarlZalph said:

If you want, then you can flag your item to be able to float on the water if you don't want it to get removed by water.

What do you mean by flag? like by adding 

MakeInventoryFloatable(inst, "idle_water", "idle")

?

 

What do you mean by flag exactly?

4 hours ago, LlamaDom said:

What do you mean by flag? like by adding 


MakeInventoryFloatable(inst, "idle_water", "idle")

?

 

What do you mean by flag exactly?

Yeah that function wrapper there would do it.

In programming, to flag something means to mark or denote.  In this case it's noting to the other subsystems that the item should float rather than get swallowed up in the water through the means of a component.  In other instances it may just be a boolean value being stored somewhere, or a bitmask getting a bit flipped.

 

You can find that function's definition in scripts/standardcomponents.lua:

function MakeInventoryFloatable(inst, size, offset, scale, swap_bank, float_index, swap_data)
    inst:AddComponent("floater")
    inst.components.floater:SetSize(size or "small")

    if offset ~= nil then
        inst.components.floater:SetVerticalOffset(offset)
    end

    if scale ~= nil then
        inst.components.floater:SetScale(scale)
    end

    if swap_bank then
        inst.components.floater:SetBankSwapOnFloat(swap_bank, float_index, swap_data)
    end
end

To make it more customized, you could look into the floater component itself to see if there's not more things you'd want to setup.

 

But all of this is to try to confront the problem head on rather than making a workaround.  From your first post it implies that having an item sink is undesirable as it kills off the entity and makes it irretrievable.

2 hours ago, CarlZalph said:

Yeah that function wrapper there would do it.

In programming, to flag something means to mark or denote.  In this case it's noting to the other subsystems that the item should float rather than get swallowed up in the water through the means of a component.  In other instances it may just be a boolean value being stored somewhere, or a bitmask getting a bit flipped.

 

You can find that function's definition in scripts/standardcomponents.lua:


function MakeInventoryFloatable(inst, size, offset, scale, swap_bank, float_index, swap_data)
    inst:AddComponent("floater")
    inst.components.floater:SetSize(size or "small")

    if offset ~= nil then
        inst.components.floater:SetVerticalOffset(offset)
    end

    if scale ~= nil then
        inst.components.floater:SetScale(scale)
    end

    if swap_bank then
        inst.components.floater:SetBankSwapOnFloat(swap_bank, float_index, swap_data)
    end
end

To make it more customized, you could look into the floater component itself to see if there's not more things you'd want to setup.

 

But all of this is to try to confront the problem head on rather than making a workaround.  From your first post it implies that having an item sink is undesirable as it kills off the entity and makes it irretrievable.

I would actually prefer for the item to sink rather than float! I thought it just might be easier to make it float rather than sink is all. 

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