#Paper Posted May 31, 2011 Share Posted May 31, 2011 I want to make some dxText in the same position for all resolutions but it doesn't work: function AbsoluteToRelativ( X, Y ) -- this coverter transforms the gui position and size for the resolution of the player local rX, rY = guiGetScreenSize() local x = math.floor((X/2200)*rX) local y = math.floor((Y/1085)*rY) return x, y end From Citizen Link to comment
SDK Posted May 31, 2011 Share Posted May 31, 2011 It seems to be correct if I understand what you need. So what doesn't work? Debug errors, wrong results, ... (show an example) Also, while technically correct, don't use the same variables names capitalized ('x' and 'X'). It's confusing and a bad scripting habit. Link to comment
Arran Posted May 31, 2011 Share Posted May 31, 2011 I belive this will help you: viewtopic.php?f=108&t=24262#p289131 Link to comment
karlis Posted June 1, 2011 Share Posted June 1, 2011 (edited) rX/x rY/y edit:srry, you have to flip it. Edited June 1, 2011 by Guest Link to comment
Callum Posted June 1, 2011 Share Posted June 1, 2011 To convert absolute to relative you simply do; relativeX = absoluteX*relativePosX relativeY = absoluteY*relativePosY Link to comment
laserlaser Posted June 1, 2011 Share Posted June 1, 2011 Use This; function AbsoluteToRelative( X, Y ) local rX, rY = guiGetScreenSize() local x = X/rX local y = Y/rY return x, y end And RelativeToAbsolute; function RelativeToAbsolute( X, Y ) local rX, rY = guiGetScreenSize() local x = X*rX local y = Y*rY return x, y end Link to comment
#Paper Posted June 2, 2011 Author Share Posted June 2, 2011 Use This; function AbsoluteToRelative( X, Y ) local rX, rY = guiGetScreenSize() local x = X/rX local y = Y/rY return x, y end And RelativeToAbsolute; function RelativeToAbsolute( X, Y ) local rX, rY = guiGetScreenSize() local x = X*rX local y = Y*rY return x, y end Ty, it works! Link to comment
Moderators Citizen Posted June 3, 2011 Moderators Share Posted June 3, 2011 I want to make some dxText in the same position for all resolutions but it doesn't work: function AbsoluteToRelativ( X, Y ) -- this coverter transforms the gui position and size for the resolution of the player local rX, rY = guiGetScreenSize() local x = math.floor((X/2200)*rX) local y = math.floor((Y/1085)*rY) return x, y end From Citizen Haha yeah I recognized my script immediately when I saw it and then I saw your credit thx dxDrawText works with absolutes arguments so you have to convert relatives arguments to absolutes arguments like laserlaser made. But something is strange, why do you have to use it ? because it's useless ! => why do you convert absolute args to relatives args and then go back to absolutes args, just take directly the absolute args. IDK if you see what I mean ... 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