Could you help me, my script doesn't work I need that when the 3 monsters are in their position you can give tp, this script with only 1 being in position can use the tp.
Lua:
local monsters = {
{name = "demon", position = {x = 655, y = 108, z = 3}},
{name = "goblin", position = {x = 665, y = 108, z = 3}},
{name = "orc", position = {x = 669, y = 108, z = 3}}
}
local lever = Action()
function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
for _, monster in ipairs(monsters) do
local tile = Tile(monster.position)
if tile then
local creature = tile:getTopCreature()
if creature and creature:isMonster() and creature:getName():lower() == monster.name then
player:say("Try your luck for the last time, you are not worthy of being here.")
doTeleportThing(player, {x=672,y=124,z=1}) -- teleport room position
doSendMagicEffect(getPlayerPosition(player), CONST_ME_TELEPORT)
return true
end
end
end
player:say("The knights are not in their positions..")
return true
end
lever:aid(25559)
lever:register()