Rabso Posted June 12, 2018 Posted June 12, 2018 (edited) Hi, I have pulling my hair for 2 days while trying to understand the EventHandler. It never works. I know MOOSE is better solution, I am still learning it but I can't resist to leave something in coding without getting it done. So, here is my basic trail code: local Event_Handler = {} function Event_Handler:onEvent(event) if (world.event.S_EVENT_TAKEOFF == event.id) then trigger.action.outText("New takeoff of unit " .. event.initiator:getName(), 10) end end world.addEventHandler(Event_Handler) it never works with me, what is wrong with this code? I tried Speed's alternate method (https://forums.eagle.ru/showpost.php?p=1591765&postcount=65) and it's working ok do local old_onEvent = world.onEvent world.onEvent = function(event) if (world.event.S_EVENT_TAKEOFF == event.id) then trigger.action.outText("New takeoff of unit " .. event.initiator:getName(), 10) end return old_onEvent(event) end end Note: to make this work I have to select continues action so can someone please help me what is wrong with my EventHandler code? Did ED change somthing? I saw several topic contain same my code and was working! Edited June 13, 2018 by Rabso i7-6700K | MSI Z170A Gaming M7 | Dominator 32GB 3000MHz | MSI GTX 1070 GAMING Z | 2TB SSD & 1TB HDD | Acer H277HU 27" WQHD | Audeze Mobius | TM Warthog | MFG Crosswind | TrackIR 5 | Windows 10 Pro
Zayets Posted June 12, 2018 Posted June 12, 2018 On your first code snippet you pass Event to the function but you call event (small case). I believe Lua is case sensitive. [sIGPIC]OK[/sIGPIC]
Rabso Posted June 13, 2018 Author Posted June 13, 2018 On your first code snippet you pass Event to the function but you call event (small case). I believe Lua is case sensitive. Ops! I believe while writing my post I changed it mistakenly. it's correct on my lua file. i7-6700K | MSI Z170A Gaming M7 | Dominator 32GB 3000MHz | MSI GTX 1070 GAMING Z | 2TB SSD & 1TB HDD | Acer H277HU 27" WQHD | Audeze Mobius | TM Warthog | MFG Crosswind | TrackIR 5 | Windows 10 Pro
Rabso Posted June 14, 2018 Author Posted June 14, 2018 I am learning more and more MOOSE and achieved the above, but I would like to understand the DCS Event Handling. Will be nice if someone could let me know what is the wrong in above code, thanks i7-6700K | MSI Z170A Gaming M7 | Dominator 32GB 3000MHz | MSI GTX 1070 GAMING Z | 2TB SSD & 1TB HDD | Acer H277HU 27" WQHD | Audeze Mobius | TM Warthog | MFG Crosswind | TrackIR 5 | Windows 10 Pro
Zayets Posted June 14, 2018 Posted June 14, 2018 There's nothing wrong with your script, I just added it in a trigger Time More than 1 sec and all is cool. [sIGPIC]OK[/sIGPIC]
Rabso Posted June 14, 2018 Author Posted June 14, 2018 There's nothing wrong with your script, I just added it in a trigger Time More than 1 sec and all is cool. :huh::dontgetit::blink: I will check again at home, thanks for your feedback i7-6700K | MSI Z170A Gaming M7 | Dominator 32GB 3000MHz | MSI GTX 1070 GAMING Z | 2TB SSD & 1TB HDD | Acer H277HU 27" WQHD | Audeze Mobius | TM Warthog | MFG Crosswind | TrackIR 5 | Windows 10 Pro
Recommended Posts