diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 6b340b19f..58baff3d6 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -1088,7 +1088,6 @@ do -- OnPlayerLeaveUnit end - --- @param #EVENT self -- @param #EVENTDATA Event function EVENT:onEvent( Event ) @@ -1250,35 +1249,34 @@ function EVENT:onEvent( Event ) return EventFunction( EventClass, Event ) end, ErrorHandler ) end - end - else - if EventData.EventUnit[Event.TgtDCSUnitName] then + end + + if EventData.EventUnit[Event.TgtDCSUnitName] then + + -- First test if a EventFunction is Set, otherwise search for the default function + if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then + + self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + end, ErrorHandler ) - -- First test if a EventFunction is Set, otherwise search for the default function - if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then - - self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end @@ -1315,31 +1313,31 @@ function EVENT:onEvent( Event ) end, ErrorHandler ) end end - else - if EventData.EventGroup[Event.TgtGroupName] then - if EventData.EventGroup[Event.TgtGroupName].EventFunction then - - self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + end + + if EventData.EventGroup[Event.TgtGroupName] then + if EventData.EventGroup[Event.TgtGroupName].EventFunction then + + self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + end, ErrorHandler ) + + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index 83fac5a55..baff5789d 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170308_2035' ) +env.info( 'Moose Generation Timestamp: 20170308_2048' ) local base = _G Include = {} @@ -5144,7 +5144,6 @@ do -- OnPlayerLeaveUnit end - --- @param #EVENT self -- @param #EVENTDATA Event function EVENT:onEvent( Event ) @@ -5306,35 +5305,34 @@ function EVENT:onEvent( Event ) return EventFunction( EventClass, Event ) end, ErrorHandler ) end - end - else - if EventData.EventUnit[Event.TgtDCSUnitName] then + end + + if EventData.EventUnit[Event.TgtDCSUnitName] then + + -- First test if a EventFunction is Set, otherwise search for the default function + if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then + + self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + end, ErrorHandler ) - -- First test if a EventFunction is Set, otherwise search for the default function - if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then - - self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end @@ -5371,31 +5369,31 @@ function EVENT:onEvent( Event ) end, ErrorHandler ) end end - else - if EventData.EventGroup[Event.TgtGroupName] then - if EventData.EventGroup[Event.TgtGroupName].EventFunction then - - self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + end + + if EventData.EventGroup[Event.TgtGroupName] then + if EventData.EventGroup[Event.TgtGroupName].EventFunction then + + self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + end, ErrorHandler ) + + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 83fac5a55..baff5789d 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170308_2035' ) +env.info( 'Moose Generation Timestamp: 20170308_2048' ) local base = _G Include = {} @@ -5144,7 +5144,6 @@ do -- OnPlayerLeaveUnit end - --- @param #EVENT self -- @param #EVENTDATA Event function EVENT:onEvent( Event ) @@ -5306,35 +5305,34 @@ function EVENT:onEvent( Event ) return EventFunction( EventClass, Event ) end, ErrorHandler ) end - end - else - if EventData.EventUnit[Event.TgtDCSUnitName] then + end + + if EventData.EventUnit[Event.TgtDCSUnitName] then + + -- First test if a EventFunction is Set, otherwise search for the default function + if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then + + self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + end, ErrorHandler ) - -- First test if a EventFunction is Set, otherwise search for the default function - if EventData.EventUnit[Event.TgtDCSUnitName].EventFunction then - - self:E( { "Calling EventFunction for UNIT ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventUnit[Event.TgtDCSUnitName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end @@ -5371,31 +5369,31 @@ function EVENT:onEvent( Event ) end, ErrorHandler ) end end - else - if EventData.EventGroup[Event.TgtGroupName] then - if EventData.EventGroup[Event.TgtGroupName].EventFunction then - - self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + end + + if EventData.EventGroup[Event.TgtGroupName] then + if EventData.EventGroup[Event.TgtGroupName].EventFunction then + + self:E( { "Calling EventFunction for GROUP ", EventClass:GetClassNameAndID(), ", Unit ", Event.TgtUnitName, EventPriority } ) + + local Result, Value = xpcall( + function() + return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + end, ErrorHandler ) + + else + + -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. + local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] + if EventFunction and type( EventFunction ) == "function" then + + -- Now call the default event function. + self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) local Result, Value = xpcall( function() - return EventData.EventGroup[Event.TgtGroupName].EventFunction( EventClass, Event ) + return EventFunction( EventClass, Event ) end, ErrorHandler ) - - else - - -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object. - local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ] - if EventFunction and type( EventFunction ) == "function" then - - -- Now call the default event function. - self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for GROUP ", EventClass:GetClassNameAndID(), EventPriority } ) - - local Result, Value = xpcall( - function() - return EventFunction( EventClass, Event ) - end, ErrorHandler ) - end end end end diff --git a/Moose Test Missions/EVT - Event Handling/EVT-201 - GROUP OnEventHit Example/EVT-201 - GROUP OnEventHit Example.miz b/Moose Test Missions/EVT - Event Handling/EVT-201 - GROUP OnEventHit Example/EVT-201 - GROUP OnEventHit Example.miz index 80540aee5..e56eefbb2 100644 Binary files a/Moose Test Missions/EVT - Event Handling/EVT-201 - GROUP OnEventHit Example/EVT-201 - GROUP OnEventHit Example.miz and b/Moose Test Missions/EVT - Event Handling/EVT-201 - GROUP OnEventHit Example/EVT-201 - GROUP OnEventHit Example.miz differ