• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved TFS 1.2 item stacking problem

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
I know that if items have different actionID's they do not stack.

However if I create a ice gem [9970] item with Game.createItem() function
and another ice gem with Player.addItem() function.
They can not be stacked?!

Both should have actionID [0]

Although there is an function I have overwritten in Lua: What I assumed caused the problem
Code:
function Item.setActionId(item, AID)
    if AID and AID >= 100 then item:setAttribute(ACTIONID, AID) end
    if not AID and item:getActionId() >= 100 then item:setAttribute(ACTIONID, 0) end
    return item
end

But now I'm not so sure, when I change both of these gem ActionID's to 0, they cant be stacked.
However If I changed them to actionID 100, they could be stacked.

creating gems only using createItem function or only with addItem() function allows me to stack them.

So whats the deal here? What am I missing.. Why I cant stack these gems??

rsxxjt.jpg
Code:
function createItem(ID, pos, count, AID, fluidType, itemText)
local item
count = count or 1
    
    if not fluidType then
        item = Game.createItem(ID, count, pos)
        
        if not item then return end
        item:setActionId(AID)
        item:setAttribute(TEXT, itemText)
        
        if count > 1 and not item:isStackable() then
            for x=1, count-1 do
                local item = Game.createItem(ID, 1, pos):setActionId(AID)
                item:setAttribute(TEXT, itemText)
            end
        end
    else
        for x=1, count do
            item = Game.createItem(ID, fluidType, pos)
            if not item then return end
            item:setActionId(AID)
            item:setAttribute(TEXT, itemText)
        end
    end
    return item
end
 
It's quite simple. When you're using the function 'createItem' you're always setting an additional attribute (text), and thus makes the item(s) unstackable.
 
It's quite simple. When you're using the function 'createItem' you're always setting an additional attribute (text), and thus makes the item(s) unstackable.
Yeah that fixed it, Ty :D

I did test setting different text attributes, but having nil or "" as attribute had no difference. So though its not an issue.
But I guess getting attribute Text simply returns "" as default value if that was not set before and the check was asked.
and orginally nil does not stack wit text ""

Idk it's complicated to explain, but I maybe you understood why I was confused here xD
(perhaps in source it should allow stacking items with attribute TEXT "" or if that was not found)
 
Back
Top