Jump to content
Sign in to follow this  
MrZig

Grid to Pos?

Recommended Posts

Hello. Would someone be able to reverse the Pos-To-Grid function and give me a Grid-To-Pos (center of the grid)? This would be invaluable and essential to my IAI.

Thanks!

Share this post


Link to post
Share on other sites

www.mapfact.net addon MAP_Misc_1.02.rar has a function script included called fString2Pos.sqf which converts grid coordinates (e.g. "Gh58") to 2D position arrays. See the addon's included MAP_Misc_ReadMe.html file for futher usage detaiils. Try that.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/* ----------------------------------------------------------------

fString2Pos by Dschulle, updated for ArmA by raedor (2006)

Version: 25/12/06

Converts a Position in String format into a 2D numerical Position

Example: _Pos = "Da64" call fString2Pos

Visit: www.mapfact.net; www.combataddons.com; www.vbs2.com

---------------------------------------------------------------- */

private["_string","_p1","_p2","_p3","_position","_letters", "_stepX1", "_stepY1", "_stepX2", "_stepY2", "_stepX3", "_stepY3"];

_string = _this;

_letters = ["A","B","C","D","E","F","G","H","I","J","a","b","c","d","e","f","g","h","i","j"];

_p1 = 0;

_position = [-1,-1];

_stepX1 = ["CfgWorlds", "Sara", "Grid", "Zoom1", "StepX"] call fGetConfigNumber; _stepX2 = _stepX1*10; _stepX3=_stepX1/2;

_stepY1 = ["CfgWorlds", "Sara", "Grid", "Zoom1", "StepY"] call fGetConfigNumber; _stepY2 = _stepY1*100; _stepY3=_stepY1/2;

while {_p1 < 10} do

{

_p2 = 10;

while {_p2 < 20} do

{

_p3 = 0;

while {_p3 < 100} do

{

if(_string == ((_letters select _p1) + (_letters select _p2) + format["%1",_p3]))then

{

_position set[0, _p1 * _stepX2 + (_p2 % 10) * _stepX1 + _stepX3];

_position set[1, _stepY2 - _p3 * _stepY1 - _stepY3];

_p1 = 10;_p2=20;_p3=100;

};

_p3 = _p3+1;

};

_p2=_p2+1;

};

_p1=_p1+1;

};

[_position select 0, 480 + (_position select 1)]

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×