Jump to content

Recommended Posts

Posted (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 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

Posted

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]

Posted
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

Posted

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

Posted

There's nothing wrong with your script, I just added it in a trigger Time More than 1 sec and all is cool.

Screen_180614_182259.thumb.jpg.35556ed4f4c6c286e35b37ee7be3f96f.jpg

[sIGPIC]OK[/sIGPIC]

Posted
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...