Molinko 43 Posted August 25, 2014 Share Posted August 25, 2014 -- Fixed: I was le tired.... I'm kinda new to OC just moved over from cc and I'm loving the mod!! I was curious if someone who knows how event.listen handles its callback function? I tried to make a simple wireless network port listener just for testing and to my avail i couldnt get it to work the way i intended... Example below: local component = require "component" local event = require "event" local modem = component.modem modem.open( 1 ) ## I was assuming that event.listen would feed the signal/event with its parameters ## to the callback function.. reason why not? I'm no pro but I figured maybe this was ## overlooked?? local function testfunc( ... ) print( ... ) -- modem_message and params should print end event.listen( "modem_message", testfunc ) -- Why you no pass params!! Sorry if this post was out of place.. Any clarification would be nice I know there are other ways to do this but i was curious. Thanks in advance I was being stupid... It was late and I was a tad drunk...Nevermind me Quote Link to post Share on other sites
Xfel 2 Posted August 27, 2014 Share Posted August 27, 2014 The event hooks and timers will only get called when event.pull() is called. So you need to add something like while true do event.pull() end Quote Link to post Share on other sites
Molinko 43 Posted September 5, 2014 Author Share Posted September 5, 2014 The event hooks and timers will only get called when event.pull() is called. So you need to add something like while true do event.pull() end I fixed my issue above. It was missing : function testfunc( ... ) print( table.unpack({ ... }) ) -- this was the issue not the listener end I imagine event.pull() is called automatically when using event.listen( event, callback ). Event listeners will even persist outside of their parent program. Handy for stuff like apis signalling sister programs from the background. Thanks for the reply. Quote Link to post Share on other sites