I was asking because for the generals file I still see calls to the old method of doing it:
local KillerUnit = Event.initiator
local KillerUnitName = Event.initiator:getName()
local KillerUnitTypeName = Event.initiator:getTypeName()
local KillerUnitCategory = Event.initiator:getDesc().category -- 0 AIRPLANE / 1 HELICOPTER / 2 GROUND_UNIT / 3 SHIP / 4 STRUCTURE
local TargetUnit = Event.target
local TargetUnitName = Event.target:getName()
local TargetUnitTypeName = Event.target:getTypeName()
local TargetUnitCategory = Event.initiator:getDesc().category -- 0 AIRPLANE / 1 HELICOPTER / 2 GROUND_UNIT / 3 SHIP / 4 STRUCTURE
Errors I get under a debug log are: 7388: attempt to concatenate local 'TargetUnitTypeName' (a nil value)
trigger.action.outText("A "..KillerUnitTypeName.." Has Killed An "..TargetUnitTypeName, 15)
Should it be updated too:
if Event.id == world.event.S_EVENT_DEAD then
if Event.initiator then
if ( Object.getCategory(Event.initiator) == 1 or Object.getCategory(Event.initiator) == 3 ) then -- UNIT or STATIC
if ( Event.initiator:getCoalition() ~= nil ) then
local DeadUnit = Event.initiator
local DeadUnitObjectCategory = Object.getCategory(Event.initiator) -- 1 UNIT / 2 WEAPON / 3 STATIC / 4 BASE / 5 SCENERY / 6 CARGO
local DeadUnitCategory = Object.getCategory(Event.initiator) -- 0 AIRPLANE / 1 HELICOPTER / 2 GROUND_UNIT / 3 SHIP / 4 STRUCTURE
local DeadUnitCoalition = Event.initiator:getCoalition()
local DeadUnitName = Event.initiator:getName()