toCylinder should be equal to backpack metatable
toCylinder is equal to player metatable
Latest source TFS 1.3
I don't think this is actually a wrong behaviour. The toCylinder is accurate in this situation cause the player is moving it to the slot not to the backpack. (So the toCylinder is the player not the backpack.)
If you have to get the backpack you should use the toPosition.y, that will give you the slot that is being moved if its >= CONST_SLOT_FIRST and <= CONST_SLOT_LAST. (You have to do that check cause otherwise its => 64 for containers).
Yes i've already fixed my problem using position, but in my opinion it is a wrong behavior, because toCylinder should be the player only when the slot is empty otherwise the backpack
Imagine you want to move a sword to a hand where there is a shield. You want toCylinder to be the hand slot or inside the shield?
Now imagine the same, instead of a shield, a backpack. The server is just being consistent when it returns the slot instead of the container.
This is debatable.
It makes sense that, if you move an item to a slot, toCylinder should be the parent of that slot. Which, in this case, is the player. It also makes sense that toCylinder should be the parent cylinder of where the item ends it's move action.
Imagine you want to move a sword to a hand where there is a shield. You want toCylinder to be the hand slot or inside the shield?
This isn't a good argument because a shield will probably never be a cylinder, while a backpack usually is.
Therefore you could use getParent in the backpack to retrieve the player, so you would just need to make a simple check if toCylinder it's either a container or a player.
So I guess it works as designed. Closing.
Most helpful comment
This is debatable.
It makes sense that, if you move an item to a slot, toCylinder should be the parent of that slot. Which, in this case, is the player. It also makes sense that toCylinder should be the parent cylinder of where the item ends it's move action.
This isn't a good argument because a shield will probably never be a cylinder, while a backpack usually is.