Fandom

武装突袭 Wiki

For forspec

简体 | 繁體

4,827个页面创建
于此维基上
添加新页面
评论0 分享

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

  

点击图片可看到更多讯息

开始使用于

游戏:
Armed Assault
版本:
1.00

描述

描述:
Creates cycle, using C like style. See example.



In Arma 3 use private keyword when defining any variables for the scope, see example 4.

基本句法

句法:
for forspec
参数:
forspec: Array
返回值:
For Type

范例

范例1:
for [{_x= 1},{_x <= 10},{_x = _x + 1}] do {debugLog _x;}

范例2:
_a = 0; for [{},{_a <= 10},{_a = _a + 1}] do {debugLog _a;};

范例3:
for [{_a = 0; _b = 1},{_a <= 10},{_a = _a + 1; _b = _b + _b}] do {}; //_a = 11; _b = 2048;

范例4:
// BAD CODE _i = 100; for [{_i = 0}, {_i < 5}, {_i = _i + 1}] do {}; hint str _i; // 5

// GOOD CODE (private keyword is recommended) _i = 100; for [{private _i = 0}, {_i < 5}, {_i = _i + 1}] do {}; hint str _i; // 100

额外资讯

多人游戏:
-
也可以看看:

Control Structuresfor dowhile

注意事项

此处撰写句法皆为可行用法. 可到官网[1]专页回报错误. 你可以使用讨论页面或是论坛来进行讨论.
新增注意事项 | 如何新增?

Notes

Posted on Apr 15, 2014 - 12:54
ffur2007slx2_5

  • Introduced with Arma 3 version 1.16
    Please note the difference between for forspec and for do, for forspec detects Boolean in each scope while for do doesn’t. e.g.
command Structure Summary
for forspec
 a = 0; b = true;
 for [{_i = 0},{_i < 10 && b},{_i = _i + 1}] do {
   a = a + 1; 
   if (a >= 7) then {b = false}
 }
loop can be exited via Boolean control, possible workaround can be like BIS_fnc_areEqual
for do
 a = 0;
 for "_i" from 0 to 10 do {
   a = a + 1;
   if (a >= 7) exitwith {}
 };
have to be exited via exitWith


  • Never try to tell a decimal number via binary number in a loop; otherwise the loop will be infinite:

for [{_a = 0},{_a != 1},{_a = _a + 0.1}] do {}; //an infinite loop; _a will never be 1 so the scope will always be true. Any binary number behind the decimal point is always the sum of 1/2, 1/4, 1/8, 1/16 etc. so decimal number with odd denominator like 1/3 or 1/10 cannot be exactly equal to each other.

  • Avoid too large factorial multiply which may loose the leading indicator in result. And 12 is the biggest accessable factor in this example.

for [{_a = 2; _b = 1;},{_a < 100},{_a = _a + 1}] do {_b = _b * _a}; // _b = 1.#INF

Bottom Section

更多维基

随机维基