Event Handling Optimization

-- Created a HandleEvent method
-- Created an UnHandleEvent method
This commit is contained in:
FlightControl
2017-02-07 13:33:29 +01:00
parent 154f729788
commit 3db8062583
95 changed files with 63884 additions and 43 deletions
@@ -0,0 +1,33 @@
---
-- Name: EVT-102 - OnEventTakeoff Example
-- Author: FlightControl
-- Date Created: 7 February 2017
--
-- # Situation:
--
-- A human plane and an AI plane are taking off from an airfield.
--
-- # Test cases:
--
-- 1. Take-Off the planes from the runway.
-- 2. When the planes take-off, observe the message being sent.
-- 3. Check the contents of the fields of the S_EVENT_TAKEOFF entry in the dcs.log file.
local PlaneAI = UNIT:FindByName( "PlaneAI" )
local PlaneHuman = UNIT:FindByName( "PlaneHuman" )
PlaneAI:HandleEvent( EVENTS.Takeoff )
PlaneHuman:HandleEvent( EVENTS.Takeoff )
function PlaneAI:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "AI Taking Off", 15, "Alert!" )
end
function PlaneHuman:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "Player " .. PlaneHuman:GetPlayerName() .. " is Taking Off", 15, "Alert!" )
end