It should be possible, but instead of counting tiles you should just compare the distance.Is there any way to send x msg to the player only if he moves any item 6 square meters away to the central Tile?
I have never seen any function related to tile counting ^^ exist?
View attachment 39444
if (math.abs(fromPosition.x - toPosition.x) >= 6 || math.abs(fromPosition.y - toPosition.y) >= 6) then
--send x Msg
end
function onRemoveItem(item, tile, position)
local itemPosition = item:getPosition()
if itemPosition:getDistance(position) >= 6 then
-- send msg
end
return true
end
Then you want to use a actionid on the tile you want this to work on, this will work for any item you remove from the tile. Unless you make a check for a special itemid in the if statement.I understand, but in my case I would like it to work only for items that are on the floor(on work with the items are in backpack for example), also two more questions, how can i declare the 2 specific target id on script? and i need this working in all tiles of map, so i need this script work in events onMoveItem? because looking here using the function onRemoveItem, i need put on specifics tiles to work.
function onRemoveItem(item, tile, position)
local tilePosition = tile:getPosition()
if tilePosition:getDistance(position) >= 6 then
-- send msg
end
return true
end
<movevent event="RemoveItem" actionid="1234" script="moveitemexample.lua" />
not specific item, i need this work with all server items moved to main tile central with the distance of 6 sqmThen you want to use a actionid on the tile you want this to work on, this will work for any item you remove from the tile. Unless you make a check for a special itemid in the if statement.
moveitemexample.lua
Lua:function onRemoveItem(item, tile, position) local tilePosition = tile:getPosition() if tilePosition:getDistance(position) >= 6 then -- send msg end return true end
add this inside
movements.xml
XML:<movevent event="RemoveItem" actionid="1234" script="moveitemexample.lua" />
hopefully i got this right, im not to familiar whit tfs 1.x+
Im only guessing that position will return the new position the item is moved to
Edit:
I missed the part where you stated that you want this to work on all tiles on the map.
Do you only want this to work only whit a specific item?
what is main tile central?
you mean there is a unique position X?
and send a message if you throw any item thats its 6sqm away from position X? or you mean main tile central as player position? can not get it