This function is for anyone wanting to get the resolution of their player's screen with one simple function. It will only work for people who use an interface file (.DMF). Also it should be noted that this will work safely with any window at all in your interface file.
How It Works
This function works by preparing a window to be rapidly expanded. When it reaches the limit of the player's screen it will stop and record how far it got in two player variables (mob/var).
Namely : currentResX & currentResY
After the process is done it will return the window back to the way it was. Now, you can use any window you like. If you choose to use any non-transparent windows then please not that there will be a 'visual flash'. You can personally stop this from happening by adding a transparent window to your interface file and calling the function on that window. For example getResolution("transparent").
To make a transparent window for this purpose, set the window's background color to something unique such as bright cyan. Then set the transparent color property of that window to the same color. It will become invisible and you're done. Now just switch your call to that window and you won't experience a flash.
Example
mob |
The Code
Simply copy paste this code into your project, it won't clash with anything you have. Now you can use it like in the example above.
Also, please note that the player's resolution variables will only update when this function is called.
mob |
there is also no reason for text2list, when there is only two values. it is probably easier, and more efficient to just parse it yourself.