Jump to content
Tiberius_161

problem getting 8 digit grids in BIS_fnc_gridToPos

Recommended Posts

Is there a way to get 8 digit grids working with BIS_fnc_gridToPos?

Right now I have a script snippet that works with 6 digits, but as soon I convert it to 8 digit  or more is gives me very strange results.

I need to 8/10 digit grids as I want to apply it in a fire support script.  

//OBJ1 is a gamelogic on the player's position;
//OBJ2 is a gamelogic that is placed on the grid position;
//The hint is the desired product;

_pos = ((["071125"] call BIS_fnc_gridToPos) param [0,[]]); 
_pos set [2,0];
OBJ2 setpos _pos;

hint format ["%1, %2, %3", (OBJ1 distance OBJ2), (OBJ1 getdir OBJ2), (round((getPosASL OBJ2) select 2))];

Any advice is appreciated. 

Share this post


Link to post
Share on other sites

From grid to pos for 10, 8 and 6 digits:

GOM_fnc_gridToPos = {
	params ["_grid"];
	_count = count _grid;
	_banana = _count / 2;
	_multis = [1,10,100];
	_counts = [10,8,6];
	_multi = _multis select (_counts find _count);
	_posX = (parseNumber (_grid select [0,_banana])) * _multi;
	_posY = (parseNumber (_grid select [_banana,_banana + _banana])) * _multi;
	[_posX,_posY,0]
};

Pos to grid:

GOM_fnc_posToGrid = {
	params ["_pos",["_gridSize",6,[0]]];
	_divisors = [100,10,1];
	_gridSizes = [6,8,10];
	_divisor = _divisors select (_gridSizes find _gridSize);
	_gridResolution = _gridSize / 2;
	_pos params ["_posX","_posY"];
	_posX = str round floor (_posX / _divisor);
	_posY = str round floor (_posY / _divisor);
	while {count _posX < _gridResolution} do {
		_posX = "0" + _posX;
	};

	while {count _posY < _gridResolution} do {
		_posY = "0" + _posY;
	};
_posX + _posY
};

Usage:

_grid = [getPosATL player,10] call GOM_fnc_posToGrid;
systemchat str _grid; //prints something like 0843103263

You can easily add finer granularity if needed.

 

Cheers

Share this post


Link to post
Share on other sites

Thnx for the help! 

 

What is the usage for GOM_fnc_gridToPos? 

 

 

Right now I pasted the whole thing in the debug dialog in the editor and tried it, but I have not succesfully got it going yet.

I tried: 

_pos = ["071250"] call GOM_fnc_gridToPos;

But it gives me an error in the 'gridto#pos'.

 

   

Share this post


Link to post
Share on other sites
1 minute ago, Tiberius_161 said:

Thnx for the help! 

 

What is the usage for GOM_fnc_gridToPos? 

 

 

Right now I pasted the whole thing in the debug dialog in the editor and tried it, but I have not succesfully got it going yet.

I tried: 


_pos = ["071250"] call GOM_fnc_gridToPos;

But it gives me an error in the 'gridto#pos'.

 

   

Returns the following just fine:

[7100,25000,0]

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites

Thnx again for your help, I redid the whole thing and got it to work! 
Problem 100% solved 

 

 

  • Like 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

×