I encountered this exact same problem, and, if I recall correctly, the exact same code, in the Scavenger Skill mod, which was also broken in the same fashion. Replacing those lines with the following fixes the problem:
for iterator = 0, n - 1 do
local addedItem = container:AddItem(item:getFullType())
container:addItemOnServer(addedItem);
end
I am pretty sure I know exactly what the problem is with the existing code. I can't find documentation, but I believe what is happening is that AddItems(string, int) is returning an array of the items added. This array's size is then used in the following iterator to get items in the container's actual inventory. This causes the wrong item to be referenced, which causes the addItemOnServer to fail. I believe that's what's occurring. Regardless, the change in code fixes the problem.
I apologize again if I was supposed to bring this up in another fashion. I've confirmed, locally, that this fixes the problem in hosted games. There may be other instances of the same problem in other traits.
I apologize in advance, not used to doing this sort of thing.
When using the Scrounger trait in a hosted game, items created by it will disappear if moved to inventory. The code in question:
https://github.com/hypnotoadtrance/MoreTraits/blob/b4686d2e09559fd995ed7a6fc94e7867b9e46b15/Contents/mods/More%20Traits/media/lua/client/MoreTraits.lua#L943-L947
I encountered this exact same problem, and, if I recall correctly, the exact same code, in the Scavenger Skill mod, which was also broken in the same fashion. Replacing those lines with the following fixes the problem:
I am pretty sure I know exactly what the problem is with the existing code. I can't find documentation, but I believe what is happening is that AddItems(string, int) is returning an array of the items added. This array's size is then used in the following iterator to get items in the container's actual inventory. This causes the wrong item to be referenced, which causes the addItemOnServer to fail. I believe that's what's occurring. Regardless, the change in code fixes the problem.
I apologize again if I was supposed to bring this up in another fashion. I've confirmed, locally, that this fixes the problem in hosted games. There may be other instances of the same problem in other traits.