Jump to content

Total LUA/coding newbie: Help with removing event handler + where to start learning how to use LUA in DCS?


Recommended Posts

Posted

How would I remove this Event handler with the world.removeEventHandler function? Everything I've tried hasn't worked. Thanks.

Quote

Handler = {}

function Handler:onEvent(event)

if event.id == world.event.S_EVENT_SHOT and event.initiator == Unit.getByName('Player') then

trigger.action.setUserFlag('200', true)

end

end

world.addEventHandler(Handler)

 

Posted

Perhaps it would be best if you showed your entire script and briefly explained what you are trying to achieve. I'm optimistic that we'll be able to sort this out quickly.

10 hours ago, GWdope said:

is (Handler) the name of the specific event handler in the script?

At least that is how *you* defined it in your code 🙂 

 

Handler = {}

Redefines "Handler" as an empty table

function Handler:onEvent(event)

Adds the function "onEvent()" to the table "Handler"

world.addEventHandler(Handler)

Adds the table "Handler" -- which must have a function "onEvent()" -- to the world's event handler.

So you'll have to invoke "removeEventHandler" with the same table "Handler" to have it removed again.

Let's go though your code and try and remove the last obstcacle

  • Recently Browsing   0 members

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