Difference between revisions of "DCS func addEventHandler"
From DCS World Wiki - Hoggitworld.com
(One intermediate revision by the same user not shown) | |||
Line 45: | Line 45: | ||
|optType2= | |optType2= | ||
− | |examples= | + | |examples= The following displays a message detailing the event that occurred: |
+ | |||
+ | local e = {} | ||
+ | function e:onEvent(event) | ||
+ | local m = {} | ||
+ | m[#m+1] = "Event ID: " | ||
+ | m[#m+1] = event.id | ||
+ | if event.initiator then | ||
+ | m[#m+1] = "\nInitiator : " | ||
+ | m[#m+1] = event.initiator:getName() | ||
+ | end | ||
+ | if event.weapon then | ||
+ | m[#m+1] = "\nWeapon : " | ||
+ | m[#m+1] = event.weapon :getTypeName() | ||
+ | end | ||
+ | if event.target then | ||
+ | m[#m+1] = "\nTarget : " | ||
+ | m[#m+1] = event.target :getName() | ||
+ | end | ||
+ | trigger.action.outText(table.concat(m), 60) | ||
+ | end | ||
+ | world.addEventHandler(e) | ||