Skip to content

Commit dc1c0fe

Browse files
committed
AUFTRAG
- Added FREIGHTTRANSPORT demo for planes
1 parent 50d1775 commit dc1c0fe

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
-- AUFTRAG: Freighttransport Plane
3+
--
4+
-- A C-130J is tasked to transport cargo from Krasnodar to Krymsk.
5+
-- The aircraft will load four ammo boxes into its internal storage.
6+
--
7+
-- These ammo boxes have to be within a 40 m radius from the plane
8+
-- before the mission can start.
9+
--
10+
-- The mission is successful if at least one cargo item makes it
11+
-- to its destination airbase.
12+
--
13+
-- If the mission is successful, the delivered cargo will be marked
14+
-- by blue smoke. This is just an example how you can access the
15+
-- cargo objects at their final destination.
16+
---
17+
18+
-- Create a FLIGHTGROUP object of the C-130
19+
local c130=FLIGHTGROUP:New("C-130 Krasnodar")
20+
21+
-- Define the set of cargo that we want to tansport
22+
local cargoset=SET_STATIC:New()
23+
cargoset:FilterPrefixes("Cargo C-130 Krasnodar")
24+
cargoset:FilterOnce()
25+
26+
-- Create a mission to transport the cargo to Krymsk airbase
27+
local mission=AUFTRAG:NewFREIGHTTRANSPORT(cargoset, AIRBASE:FindByName(AIRBASE.Caucasus.Krymsk))
28+
29+
-- Assign mission to C-130
30+
c130:AddMission(mission)
31+
32+
-- Do something with the cargo, once it has been delivered
33+
function mission:OnAfterSuccess(From, Event, To)
34+
35+
local cargoset=mission:GetCargoSet()
36+
37+
local function smoke(_static)
38+
local static=_static --Wrapper.Static#STATIC
39+
static:SmokeBlue()
40+
end
41+
42+
cargoset:ForEach(smoke)
43+
44+
end

0 commit comments

Comments
 (0)