kevenvz Posted September 20, 2013 Share Posted September 20, 2013 Hey i got this code and it wont return the function. Can anybody help? addEventHandler("onClientClick",root, function(button,state) if (button ~= "left") or (state ~= "down") then return end for _,dxElement in pairs(getElementsByType("dxButton")) do local posX,posY = getCursorPosition() local screenWidth,screenHeight = guiGetScreenSize() local mouseX, mouseY = posX * screenWidth, posY * screenHeight if (mouseX >= AbsoluteToRelativX(getElementData(dxElement,"x"))) and (mouseX <= AbsoluteToRelativX(getElementData(dxElement,"x") + getElementData(dxElement,"width"))) and (mouseY >= AbsoluteToRelativX(getElementData(dxElement,"y"))) and (mouseY <= AbsoluteToRelativX(getElementData(dxElement,"y") + getElementData(dxElement,"height"))) then return getElementData(dxElement,"handledFunction") end end end) setElementData(dxElement,"handledFunction",testFunction) function testFunction() outputDebugString("TEST DONE!") end Link to comment
Castillo Posted September 20, 2013 Share Posted September 20, 2013 You are defining the function after you set the element data. Link to comment
kevenvz Posted September 20, 2013 Author Share Posted September 20, 2013 Its 2 different codes, actually it is: statsButton = dxCreateButton(10, 910, 130, 130, "files/stats.png", "Stats", tocolor(255, 255, 255, 255), 1, "bankgothic", "center", "bottom", false, true, testFunction, botBar) I am working on my own dx library but it sets all the elements data then it renders it and then it should trigger which it won't! Edit: I can give yoy the source but please dont leak it! I will release it soon so Link to comment
Moderators IIYAMA Posted September 21, 2013 Moderators Share Posted September 21, 2013 you are returning to a handler function, with that you are also breaking your main loop. Link to comment
kevenvz Posted September 22, 2013 Author Share Posted September 22, 2013 So any solution of making this? I would love to have this! Link to comment
Moderators IIYAMA Posted September 22, 2013 Moderators Share Posted September 22, 2013 well I am not going to find all code mistakes... But: testFunction(getElementData(dxElement,"handledFunction")) break instead of: return getElementData(dxElement,"handledFunction") 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