Ichito123
New Member
- Joined
- Nov 25, 2013
- Messages
- 36
- Reaction score
- 3
If the topic is already there, I just hook it up and put it into a logical whole.
We enter the directory:
data/events/script/player.lua
then we look for a function:
It might look like this:
We add another function under this one.
As you can imagine, this function allows you to put only 4 items on each other.
I was looking for a working code for a long time and this one flashes for me I hope it will be useful to someone.
We enter the directory:
data/events/script/player.lua
then we look for a function:
Lua:
Player:onMoveItem
It might look like this:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if fromPosition:isInRange(MATCH.BOARD.from, MATCH.BOARD.to) then
self:sendCancelMessage('Sorry, not possible.')
return false
end
if toPosition:isInRange(MATCH.BOARD.from, MATCH.BOARD.to) then
self:sendCancelMessage('Sorry, not possible.')
return false
end
return true
end
We add another function under this one.
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
local tile = Tile(toPosition)
local max = 4
if tile then
if #tile:getItems() >= max then
self:sendTextMessage(MESSAGE_STATUS_SMALL, 'This tile has the max amount of items on it already.')
return false
end
end
return true
end
As you can imagine, this function allows you to put only 4 items on each other.
Code:
local max = 4
I was looking for a working code for a long time and this one flashes for me I hope it will be useful to someone.