mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
28 lines
537 B
Lua
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
|