Skip to content

Commit 77257fd

Browse files
authored
Lua: fix RegisterObjectDestroyedEvent condition (dkfans#4831)
1 parent fce7dce commit 77257fd

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

config/fxdata/lua/triggers/Builtins.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- Entry points for engine-triggered events (e.g. OnPowerCast, OnGameTick).
33
-- These functions are called by the C engine and dispatch event data to the Lua trigger system.
44

5-
---@alias event_type "PowerCast"|"Death"|"SpecialActivated"|"GameTick"|"ChatMsg"|"DungeonDestroyed"|"TrapPlaced"|"ApplyDamage"|"LevelUp"|"Rebirth"|"SlabKindChange"|"SlabOwnerChange"|"RoomOwnerChange"|"ShotHitThing"
5+
---@alias event_type "PowerCast"|"Death"|"SpecialActivated"|"GameTick"|"ChatMsg"|"DungeonDestroyed"|"TrapPlaced"|"ApplyDamage"|"LevelUp"|"Rebirth"|"SlabKindChange"|"SlabOwnerChange"|"RoomOwnerChange"|"ShotHitThing"|"Destroyed"
66

77
--- Called when a spell is cast on a unit
88
--- @param pwkind power_kind
@@ -31,10 +31,10 @@ function OnCreatureDeath(unit)
3131
end
3232

3333
--- Called when an object is destroyed
34-
--- @param unit Object The unit that dies
35-
function OnObjectDestroyed(unit)
34+
--- @param object Object The object that is destroyed
35+
function OnObjectDestroyed(object)
3636
local eventData = {}
37-
eventData.unit = unit
37+
eventData.object = object
3838
ProcessEvent("Destroyed",eventData)
3939
end
4040

config/fxdata/lua/triggers/Events.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ end
119119
---@param object? Object the object that triggers the event
120120
---@return table
121121
function RegisterObjectDestroyedEvent(action, object)
122-
local trigData = {thing = object}
122+
local trigData = {object = object}
123123

124124
local trigger = CreateTrigger("Destroyed",action,trigData)
125-
if unit then
125+
if object then
126126
TriggerAddCondition(trigger, function(eventData,triggerData) return eventData.object == triggerData.object end)
127127
end
128128
return trigger

0 commit comments

Comments
 (0)