Jump to content

Recommended Posts

In my mod, when certain conditions are triggered, the mod executes the following logic:

```lua
if self.inst:HasTag("in_kitchen") then
    loot.components.edible.healthvalue = 200
    loot:AddTag("kitchen_buff")
    --loot.skinname = "my_cool_skin"
    local loot_name = loot:GetBasicDisplayName()
    loot.displaynamefn = function()
        return loot_name .. "(kitchen_buff)"
    end
end
```

In simple terms, under certain circumstances, the crockpot produces a food entity that differs from the original version. The only difference between this food entity and the original is that it restores more health when consumed: `loot.components.edible.healthvalue = 200`. To distinguish it from the original food in display, I changed its display name to "original name (kitchen_buff)". However, since Don't Starve's stacking mechanism appears to only consider prefab and skinname: `item.prefab == self.inst.prefab and item.skinname == self.inst.skinname`, modifying this judgment logic would require altering a large amount of source code related to inventory.

For example, for `Inventory:GetNextAvailableSlot(item)`, I would need to add a series of additional conditions such as `v:HasTag("kitchen_buff") == item:HasTag("kitchen_buff")` within its judgment logic. This is too cumbersome. Moreover, even after adding an additional condition in these places, two different types of food may still stack together. I would like to ask if there is a better way to achieve this.

(Additional note: There is a workaround—modifying the food's skinname: `loot.skinname = "something different"`. This immediately solves all the above problems, but I wonder if doing so carries any risks.)

 

^The video above demonstrates this bug

 

Edited by lizzary

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