Kleinbart Posted April 4, 2021 Share Posted April 4, 2021 Hi guys This is working: local event_handler = {} function event_handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then --or any other event trigger.action.outText('Hello World' ,10 ,1) end end world.addEventHandler(event_handler) And this doesn't work: function doNothing() trigger.action.outText('Hello World' ,10 ,1) end local event_handler = {} function event_handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then doNothing end end world.addEventHandler(event_handler) Anyone knows why? Thanks for your answer. Link to comment Share on other sites More sharing options...
Chump Posted April 4, 2021 Share Posted April 4, 2021 doNothing() Link to comment Share on other sites More sharing options...
Kleinbart Posted April 4, 2021 Author Share Posted April 4, 2021 i forgott the () only here. In the real script i have the (). But it doesent work. Link to comment Share on other sites More sharing options...
Hardcard Posted April 5, 2021 Share Posted April 5, 2021 Paste the EXACT script you're using. [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Kleinbart Posted April 5, 2021 Author Share Posted April 5, 2021 here the exact script: works: local event_handler = {} function event_handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then -- or any other event trigger.action.outText('Hello World' ,10 ,1) end end world.addEventHandler(event_handler) dosen't work: function helloWorld() trigger.action.outText('Hello World' ,10 ,1) end local event_handler = {} function event_handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then -- or any other event helloWorld() end end world.addEventHandler(event_handler) Link to comment Share on other sites More sharing options...
dark_wood Posted April 5, 2021 Share Posted April 5, 2021 Maybe your function needs to be global: helloWorld = function() trigger.action.outText('Hello World' ,10 ,1) end local event_handler = {} function event_handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then -- or any other event helloWorld() end end world.addEventHandler(event_handler) Link to comment Share on other sites More sharing options...
Kleinbart Posted April 5, 2021 Author Share Posted April 5, 2021 I tested with global function. It still doesen't work. Link to comment Share on other sites More sharing options...
toutenglisse Posted April 5, 2021 Share Posted April 5, 2021 I took the script that doesn't work, and just re-wrote few things the way I'd do and used MIST eventhandler, and it works : function doNothing() trigger.action.outText('Hello World' ,10 ,true) end function crashtest(event) if event.id == world.event.S_EVENT_CRASH then doNothing() end end CrashID = mist.addEventHandler(crashtest) That said I can't tell where and why your script is failing - crashtest on Khalifa tower .miz file attached. 3 hours ago, Kleinbart said: I tested with global function. It still doesen't work. test-crash-event.miz Link to comment Share on other sites More sharing options...
Kleinbart Posted April 5, 2021 Author Share Posted April 5, 2021 So i will use MIST. Thanks a lot for helping. Link to comment Share on other sites More sharing options...
Recommended Posts