• 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!

Making items in a stack have different values.

Sportacus

Intermediate OT User
Joined
Aug 3, 2008
Messages
718
Reaction score
100
I want to change how items in a stack work, to make each item in the stack to have it's own properties.

This became an issue for me, because I wanted fresh meat and food in general to be able to decay into a rotten version. With how the system works now, if a single item is decaying, if it is brought into another stack, it wipes the info from it, and just takes the value of the stack.

This could also be applied in other ways, such as having arrows that have varying stats.


I guess the way it should work, is that any 'stackable' item should kinda work like a container, that can only accept items of the same ID. And inside of the stack (container) we would have each piece of the stack listed individually.

You could use items by using the 'main stack'/"container" item, and it would just use the first one in the list.

I need help with this, as I have no clue where to start to get this to work, so I thought I would throw it out into a support thread.
 
Last edited:

If you are using TFS 1.x you can use the event Player:eek:nMoveItem using the positions.

Here is a start:

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
   local itemtype = ItemType(item:getId())
   if itemtype:isStackable() then
     if toPosition.x == CONTAINER_POSITION then
       local container = self:getContainerById(toPosition.y-64)
       local moveToItem = container:getItem(toPosition.z)
       local exactstack = false

      
       -- This is the if for when the player move the item to the exact stack.
       if moveToItem then
         if item:getId() == moveToItem:getId() then
           exactstack = true
           -- do something
         end
       end

       -- Here is the if for the auto stack, it does only work when the fromPosition and toPosition container id is different
       if not exactstack and container:getItemCountById(item:getId()) > 0 and fromPosition.y ~= toPosition.y then
         -- get the first item from the container and do something
       end
     end
   end
   return true
end

Of course this is only for the stacking inside a container, you still need to do the part to check if the item is being stacked outside containers or container -> floor.

Well atleast I gave you a starting point :p good luck!

Edit: Fixed some issues in the code.

Edit2: Hmm it seems that the TFS uses only the auto stack so even if you move to the exact stack of an item it will auto stack to the first of the container. So you can remove the if for the exact stack.
 
Last edited:
Back
Top