1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/scripts/lib/erm/OB_T.lua
2021-02-16 13:32:18 +03:00

28 lines
537 B
Lua

local TriggerBase = require("core:erm.TriggerBase")
local ObjectVisitStarted = require("events.ObjectVisitStarted")
local eventBus = EVENT_BUS
local game = GAME
local trigger = TriggerBase:new()
function trigger:new(o)
o = TriggerBase.new(self, o)
local id1 = tonumber(o.id[1])
o.sub = ObjectVisitStarted.subscribeBefore(eventBus,
function(event)
local objIndex = event:getObject()
local obj = game:getObj(objIndex, false)
if obj:getObjGroupIndex() == id1 then
o:call(event)
end
end)
return o
end
return trigger