BrastaSauce Posted April 4, 2014 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
Controlled Posted April 4, 2014 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?
BrastaSauce Posted April 4, 2014 Author Posted April 4, 2014 Screenx gave me a boolean, while screeny gave me nil for some reason.
Plean Posted April 4, 2014 Posted April 4, 2014 From wiki page: If the cursor isn't showing, returns false as the first value.
Karuzo Posted April 4, 2014 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.
Mr_Moose Posted April 4, 2014 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.
tosfera Posted April 4, 2014 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
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