DarkLink Posted July 7, 2012 Share Posted July 7, 2012 Is possible to pass arguments to the function that is called from the handler?? I mean.. I have this handler: function() local x,y = 10,50 addEventHandler("onClientRender", getRootElement(), doSomething) end function doSomething() -- HOW can I have access here to that arguments above? the x and the y ? thanks alot in advance... end EDIT: I tryed this but doesnt work ! addEventHandler("onClientRender", getRootElement(), showInfoAboutTimes(x,y)) Gives me this error : [2012-07-07 20:43:28] WARNING: bp\client_testbar.lua:11: Bad argument @ 'addEventHandler' [Expected function at argument 3, got none] Thanks again Link to comment
GTX Posted July 7, 2012 Share Posted July 7, 2012 What do you mean? Do you mean this? function doSomething() outputChatBox("X: " .. x .. " Y: " .. y) end Link to comment
TAPL Posted July 7, 2012 Share Posted July 7, 2012 make it global, without local function() x,y = 10,50 addEventHandler("onClientRender", getRootElement(), doSomething) end function doSomething() -- HOW can I have access here to that arguments above? the x and the y ? thanks alot in advance... end Link to comment
DarkLink Posted July 7, 2012 Author Share Posted July 7, 2012 Yes I know that I can make them global.. and use them normally... but if I dont want it global ? just local on that scope? and then give it to that function that is called on the event handler ? not possible ? Link to comment
Anderl Posted July 7, 2012 Share Posted July 7, 2012 addEventHandler( 'onClientRender', root, function( ) doSomething( x, y ); end ); Link to comment
DarkLink Posted July 7, 2012 Author Share Posted July 7, 2012 addEventHandler( 'onClientRender', root, function( ) doSomething( x, y ); end ); Ahhh right! Forgot about this way ehhe Thanks alot mate Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now