Example Code: Convert Position To Map Grid: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|arma|" to "|arma1|")
m (Text replacement - "\{\{( *)Informative( *)\|" to "{{$1Feature$2|$2Informative$2|")
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.00}} {{GVI|arma2|1.04}}}}
{{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.00}} {{GVI|arma2|1.04}}}}
{{Informative |
{{Feature | Informative |
* [[mapGridPosition]] has been introduced in {{GVI|arma2|1.04}}
* [[mapGridPosition]] has been introduced in {{GVI|arma2|1.04}}
}}
}}
Line 9: Line 9:


{{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}}
{{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}}
{{Informative |
{{Feature | Informative |
* [[BIS_fnc_posToGrid]] has been introduced in {{GVI|arma2|1.00}}
* [[BIS_fnc_posToGrid]] has been introduced in {{GVI|arma2|1.00}}
}}
}}
Line 17: Line 17:


{{ArgTitle|{{arma1}}|2|{{GVI|arma1|1.00}}}}
{{ArgTitle|{{arma1}}|2|{{GVI|arma1|1.00}}}}
{{Informative|
{{Feature|Informative|
* [[floor]] has been introduced in {{GVI|arma1|1.00}}
* [[floor]] has been introduced in {{GVI|arma1|1.00}}
}}
}}
Line 40: Line 40:


{{ArgTitle|{{ofp}}|2|{{GVI|ofp|1.00}}}}
{{ArgTitle|{{ofp}}|2|{{GVI|ofp|1.00}}}}
{{Informative | This is an [[SQS syntax]] example.}}
{{Feature | Informative | This is an [[SQS syntax]] example.}}


  {{codecomment|; given grid squares are 200 × 200}}
  {{codecomment|; given grid squares are 200 × 200}}

Revision as of 00:01, 7 February 2021

2

private _mapGridPosition = mapGridPosition player;


2

private _mapGridPosition = player call BIS_fnc_posToGrid;


2

private _gridSize = 200; // given grid squares are 200 × 200
private _yOffset = -280; // position [0,0,0] is somewhere in the middle of second big grid on Y axis

private _xPos = floor ((_this select 0) / _gridSize);
private _yPos = floor (((_this select 1) + _yOffset) / _gridSize);

private _letter1Index = floor (_xPos / 10);
private _letter2Index = floor (_xPos % 10);
private _letter1Choice = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"];
private _letter2Choice = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
private _letter1 = _letter1Choice select _letter1Index;
private _letter2 = _letter2Choice select _letter2Index;

private _numbers = 100 - _yPos; // coordinate numbers start from top-left of the map

private _mapGridPosition = format ["%1%2%3", _letter1, _letter2, _numbers];


2

This is an SQS syntax example.
; given grid squares are 200 × 200
private _gridSize = 200

; position [0,0,0] is somewhere in the middle of second big grid on Y axis
private _yOffset = -280

private _xPos = (_this select 0) / _gridSize
private _yPos = ((_this select 1) + _yOffset) / _gridSize
_xPos = _xPos - (_xPos mod 1)
_yPos = _yPos - (_yPos mod 1)

private _letter1Index = _xPos / 10
private _letter2Index = _xPos % 10
_letter1Index = _letter1Index - (_letter1Index mod 1)
_letter2Index = _letter2Index - (_letter2Index mod 1)
private _letter1Choice = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
private _letter2Choice = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
private _letter1 = _letter1Choice select _letter1Index
private _letter2 = _letter2Choice select _letter2Index

coordinate numbers start from top-left of the map
private _numbers = 100 - _yPos

private _mapGridPosition = format ["%1%2%3", _letter1, _letter2, _numbers]