BrastaSauce Posted April 4, 2014 Share Posted April 4, 2014 (edited) I get an error for attempting to compare a number with a boolean on line 4. addEventHandler("onClientRender", root, function() local screenx, screeny, worldx, worldy, worldz = getCursorPosition() if (screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then redMessage = dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 0, 0, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) else dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) end addEventHandler("onClientGUIClick", redMessage, clickOnMessage) end ) Edited April 4, 2014 by Guest Link to comment
Controlled Posted April 4, 2014 Share Posted April 4, 2014 Use lua tags so it's easier for us to read. What does debug output for the values of screenx and screeny? Link to comment
BrastaSauce Posted April 4, 2014 Author Share Posted April 4, 2014 Screenx gave me a boolean, while screeny gave me nil for some reason. Link to comment
Plean Posted April 4, 2014 Share Posted April 4, 2014 From wiki page: If the cursor isn't showing, returns false as the first value. Link to comment
Karuzo Posted April 4, 2014 Share Posted April 4, 2014 screenx and screeny returns a value between 0 and 1 so you can't compare it with 924 just let your cursors position output and then compare it. Link to comment
Mr_Moose Posted April 4, 2014 Share Posted April 4, 2014 Replace this: if (screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then With this: if (screenx and screeny and screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then And the if statement will verify that screenx and screeny has a value that isn't false (which will output the error you received). The root of this problem is as Plean said: "If the cursor isn't showing, returns false as the first value.", another option could be o check if the cursor is showing in this if statement as well. Link to comment
tosfera Posted April 4, 2014 Share Posted April 4, 2014 An easier way would to to just add a simple check to your script above the getCursorPosition() and let it quit the script whenever your cursor isn't showing; if not ( isCursorShowing() ) then return; end 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