getPos – Talk
Killzone Kid (talk | contribs) |
Lou Montana (talk | contribs) m (Text replacement - " <!-- (DIS)?CONTINUE Notes -->" to "") |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 13: | Line 13: | ||
::Oh... I'm sorry, my bad; I'll try that out! Thanks a lot for answering Mr. Spanel. --[[User:Deusrexmachina|Deusrexmachina]] 18:12, 17 August 2006 (CEST) | ::Oh... I'm sorry, my bad; I'll try that out! Thanks a lot for answering Mr. Spanel. --[[User:Deusrexmachina|Deusrexmachina]] 18:12, 17 August 2006 (CEST) | ||
===Arma 3=== | === Arma 3 === | ||
====Altis==== | ==== Altis ==== | ||
If I use getpos (ex. getpos player) the X and Y only has '''1''' digit behind the dot. | If I use getpos (ex. getpos player) the X and Y only has '''1''' digit behind the dot. | ||
If I examine the mission.sqm file, there are up to '''4''' digits after the dot. | If I examine the mission.sqm file, there are up to '''4''' digits after the dot. | ||
====Stratis==== | ==== Stratis ==== | ||
If I use getpos (ex. getpos player) the X and Y only has '''2''' digit behind the dot. | If I use getpos (ex. getpos player) the X and Y only has '''2''' digit behind the dot. | ||
If I examine the mission.sqm file, there are up to '''4''' digits after the dot. | If I examine the mission.sqm file, there are up to '''4''' digits after the dot. | ||
Line 68: | Line 68: | ||
Good one! I went in a slightly different way, completely forgot about % and as a result managed to achieve even better precision | Good one! I went in a slightly different way, completely forgot about % and as a result managed to achieve even better precision | ||
2518.51 default number to string | 2518.51 default number to string | ||
2518.512695 using modulo | 2518.512695 using modulo | ||
2518.51268555 using my method | 2518.51268555 using my method | ||
The only thing is it is easier to store this precision as 2 strings rather than 1. Going to put this method on my blog tomo if you are interested. | The only thing is it is easier to store this precision as 2 strings rather than 1. Going to put this method on my blog tomo if you are interested. | ||
--[[User:Killzone_Kid|Killzone_Kid]] 13 December 2013 | --[[User:Killzone_Kid|Killzone_Kid]] 13 December 2013 | ||
<dl class="command_description"> | |||
<dt></dt> | |||
<dd class="notedate">Posted on October 4, 2014 - 03:08 (UTC)</dd> | |||
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt> | |||
<dd class="note"> | |||
[http://forums.bistudio.com/showthread.php?183933-CODE-SNIPPET-amp-Extremely-important-note-regarding-position-accuracy-(to-some) I wrote a post in the Arma3 section of the forums regarding accuracy of this command because of rounding, along with a small workaround I developed. (click here) Untested, but this issue probably exists in Arma2 as well.] | |||
</dd> | |||
</dl> |
Latest revision as of 00:54, 6 April 2021
Hello. There is one command missing in the list shown here and in other sites:
getVel
I have NO idea which version this came out from, but I've seen it thanks to one boy -I really can't recall where I got his script- who has done a personal bombing script. I've then tried myself to change some stuff of his and noticed this command that isn't listed in major sites! It works just like getPos; I myself still have to learn it properly, and am still far away from being good in scripts.
If anyone has more info 'bout this, PLEASE post what you know! Thanks.
- Oh... I'm sorry, my bad; I'll try that out! Thanks a lot for answering Mr. Spanel. --Deusrexmachina 18:12, 17 August 2006 (CEST)
Arma 3
Altis
If I use getpos (ex. getpos player) the X and Y only has 1 digit behind the dot. If I examine the mission.sqm file, there are up to 4 digits after the dot.
Stratis
If I use getpos (ex. getpos player) the X and Y only has 2 digit behind the dot. If I examine the mission.sqm file, there are up to 4 digits after the dot.
This is very inaccurate
Anyone else has the same behaviour? If there are more with the same behaviour, I would go and open a issue @feedback.
--HeliJunkie 20:51, 10 December 2013 (CET)
This has something to do with the number format in Arma. You can only have 6 digits doesn't matter integer or float. For example 999999 is the biggest number you can have before it starts to get rounded, and -999999 is the smallest. If you go float then the smaller the number the better precision: 9.99999, 99.9999, 999.999, 9999.99, 99999.9. The unfortunate thing about this number handling is that the further away you are from the origin of the map [0,0,0] the worse the position precision.
--Killzone_Kid 13 December 2013
Hey, thanks for that hint! It has to do with formating a number to a string (not (only) with the internaly number format).
Try this code:
_num = 123456.123456789; _num2 = 0; if (_num >= 0) then { // strip "0." after modulo (_num % 1 => 0.125) _num2 = [str(_num % 1), 2] call BIS_fnc_trimString; } else { // strip "-0." after modulo (for negative numbers) _num2 = [str(_num % 1), 3] call BIS_fnc_trimString; }; _numString = format["%1.%2",(round _num), _num2]; hint format["Default: %1\nNumString: %2",_num, _numString];
Result should be:
Default: 123456 NumString: 123456.125
This is a little bit closer to the real number
More examples:
12345.123456789 => 12345.123047 1234.123456789 => 1234.123413 123.123456789 => 123.123459 12.123456789 => 12.123457
So of course there is already the limit of 6 digits while formating the number after the dot.
--HeliJunkie 22:19, 13 December 2013 (CET)
Good one! I went in a slightly different way, completely forgot about % and as a result managed to achieve even better precision
2518.51 default number to string 2518.512695 using modulo 2518.51268555 using my method
The only thing is it is easier to store this precision as 2 strings rather than 1. Going to put this method on my blog tomo if you are interested.
--Killzone_Kid 13 December 2013