Last active
July 13, 2016 15:31
-
-
Save pennyworth12345/accec187c713140810a5ee20855f23eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For use in Eden Editor UI to copy mapSize and icon to clipboard, only needs to be executed once to save the function to variable | |
getMapSizeAndIcon = { | |
params ["_object"]; | |
_bbr = boundingBoxReal _object; | |
_p1 = _bbr select 0; | |
_p2 = _bbr select 1; | |
_maxWidth = abs ((_p2 select 0) - (_p1 select 0)); | |
_maxLength = abs ((_p2 select 1) - (_p1 select 1)); | |
_mapSize = _maxWidth max _maxLength; | |
_mapSize = (round (_mapSize * 100)) / 100; | |
_ratio = -1; | |
_switch = -1; | |
if(_maxWidth > _maxLength) then { | |
_ratio = _maxWidth / _maxLength; | |
_switch = 0; | |
} else { | |
_ratio = _maxLength /_maxWidth; | |
_switch = 1; | |
}; | |
_arr = [ | |
[abs(1 - _ratio), ["1","1"]], | |
[abs(5 - (_ratio*4)), ["5","4"]], | |
[abs(3 - (_ratio*2)), ["3","2"]], | |
[abs(2 - (_ratio*1)), ["2","1"]], | |
[abs(5 - (_ratio*2)), ["5","2"]], | |
[abs(3 - _ratio), ["3","1"]], | |
[abs(4 - _ratio), ["4","1"]], | |
[abs(5 - _ratio), ["5","1"]], | |
[abs(7 - _ratio), ["7","1"]], | |
[abs(10 - _ratio), ["10","1"]] | |
]; | |
_arr sort true; | |
_first = (_arr select 0) select 1; | |
_val = ""; | |
if(_switch isEqualTo 0) then { | |
_val = format ["%1x%2", (_first select 0), (_first select 1)]; | |
} else { | |
_val = format ["%1x%2", (_first select 1), (_first select 0)]; | |
}; | |
_br = toString [13,10,9,9]; | |
_stringMap = format ["mapSize = %1;", _mapSize]; | |
_stringIcon = format ["icon = ""iconObject_%1"";", _val]; | |
copyToClipboard (_stringMap + _br + _stringIcon); | |
}; | |
//Run the following line to copy the mapSize and icon for the selected object to clipboard | |
(get3DENSelected "object" select 0) call getMapSizeAndIcon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment