1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/scripts/lib/erm/OB_T.lua

28 lines
537 B
Lua
Raw Normal View History

2021-02-15 16:16:41 +02:00
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