cristianso
Member
- Joined
- Jan 27, 2019
- Messages
- 47
- Reaction score
- 16
I have this script that remove a stone when you pull the lever. After a while, the stone is created on the same spot.
However, if the player in on the same position of the stone, the stone is not created... So, I need to move the player 1 sqm away if he is on the same spot of the stone.
However, if the player in on the same position of the stone, the stone is not created... So, I need to move the player 1 sqm away if he is on the same spot of the stone.
LUA:
local stonePositions = {
Position(14773, 13605, 9)
}
local function createStones()
for i = 1, #stonePositions do
Game.createItem(1353, 1, stonePositions[i])
end
end
local function revertLever(position)
local leverItem = Tile(position):getItemById(1946)
if leverItem then
leverItem:transform(1945)
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid ~= 1945 then
return false
end
local stone
for i = 1, #stonePositions do
stone = Tile(stonePositions[i]):getItemById(1354)
if stone then
stone:remove()
stonePositions[i]:sendMagicEffect(CONST_ME_EXPLOSIONAREA)
end
end
addEvent(createStones, 12 * 1000)
item:transform(1946)
addEvent(revertLever, 12 * 1000, toPosition)
return true
end