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

Cylinder explanation

zxmatzx

Advanced OT User
Joined
Dec 1, 2010
Messages
312
Solutions
27
Reaction score
155
Location
Brazil
GitHub
Mateuso8
Hello,
Someone could explain me about:

TFS 1.2
events/scripts/player.lua:
Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

fromCylinder and toCylinder.
What does it mean, how does it work, what uses?

Im trying to do a system, to block player to Drop, Trade, Move items that have a X actionId, how can i know if player is moving the item to depot container, or a container inside the depot?
 
Solution
If you want to get depot or if player is moving an item inside a depot you can use something like this
Lua:
if toCylinder and toCylinder:isItem() then
    if toCylinder:getId() == depot_id or toCylinder:getTopParent():getId() == depot_id then
        print('Item id ('.. item:getId() ..') moved to depot')
    end
end

The xyz values I demonstrated are just from the positions themselves, not cylinders.
cylinder is container.

a backpack,
depot chest,
a empty corpse.
How can i access it? What properties the userdata have? How and Where can i check this? Can u show me some exemples?
If i move one item, from Backpack, to ground, i have ToPosition and don't have ToCylinder? If i can see how is functions, i can test by myself.
Thanks for your reply.
 
A cylinder is a class used to represent anything that can hold items within it, which includes player inventory, any type of container, and tiles.
 
check otland thread, is a lot !!!
also you can check tfs functions.
I did, and keep doing that... Belive me...

I don't understand what you wanted to show me on this Thread, I did not see anything about Cylinder there...

A cylinder is a class used to represent anything that can hold items within it, which includes player inventory, any type of container, and tiles.
Yeah, i got it... But how to access data, like determine if is playerInventory, a tile, a backpack, a depot container.

I found this topic where u give a nice idea about cylinders, but how i get x, y and z values that u show in the exemple?

i never actually answered your question, i just answered why it happens
you can get the item (not through candybot) through the player event called onMoveItem.
onMoveItem has fromCylinder and toCylinder arguments which both hold values of (you guessed it) the last cylinder userdata the item was at, and the cylinder userdata of the item being thrown into.
i also forgot to say cylinder z positions are the index of which the item is (indexing starts at 0 rather than 1)
so if i have a brown backpack inventory, and i move a blue backpack inside of it from index 0 in my backpack (the first slot) into a red backpack with index 3 (the fourth slot), fromCylinder and toCylinder will be the same cylinder because i'm still technically moving it from the brown backpack (from cylinder) to the brown backpack (to cylinder)

fromCylinder position in the above case would be: (X: 65535, Y: 64, Z: 0)
toCylinder position would be: (X: 65535, Y: 64, Z: 3)

moving the blue backpack back to the original brown backpack would then be different cylinders, since fromCylinder would be the red backpack (the backpack i moved the blue backpack inside to), and toCylinder would be the brown backpack.
the positions would be:

fromCylinder: (X: 65535, Y: 65, Z: 0)
toCylinder: (X: 65535, Y: 64, Z: max backpack size) (moving to new cylinder z position is the number of max items held + 1)
 
If you want to get depot or if player is moving an item inside a depot you can use something like this
Lua:
if toCylinder and toCylinder:isItem() then
    if toCylinder:getId() == depot_id or toCylinder:getTopParent():getId() == depot_id then
        print('Item id ('.. item:getId() ..') moved to depot')
    end
end

The xyz values I demonstrated are just from the positions themselves, not cylinders.
 
Solution
If you want to get depot or if player is moving an item inside a depot you can use something like this
Lua:
if toCylinder and toCylinder:isItem() then
    if toCylinder:getId() == depot_id or toCylinder:getTopParent():getId() == depot_id then
        print('Item id ('.. item:getId() ..') moved to depot')
    end
end

The xyz values I demonstrated are just from the positions themselves, not cylinders.
Thanks, now I understood how to use the functions in the Cylinders.
 
Back
Top