Fandom

武装突袭 Wiki

Params

简体 | 繁體

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

您使用了广告屏蔽软件!


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

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

Introduced with Arma 3 version 1.48
  

点击图片可看到更多讯息

开始使用于

游戏:
Arma 3
版本:
1.48

描述

描述:
Parses input argument into array of private variables, similar to BIS_fnc_param. When used without argument, as shown in main syntax, internal variable _this, which is usually available inside functions and event handlers, is used as argument.

In addition to simple parsing directly into variables, input can be tested in case it is undefined, of the wrong type or of the wrong size (if array) and substituted if necessary with default values. Since Arma 3 v1.53.132691, onscreen errors are displayed for when the input is of the wrong type or size.

基本句法

句法:
params [element1, element2,...elementN]
参数:
[element1, element2,...elementN]: Array - format array

elementN: String or Array
If String then it is the name of a private variable (must begin with underscore _, e.g. "_myVar")
If Array then it should be one of the following constructs:

  • [variableName, defaultValue]
  • [variableName, defaultValue, expectedDataTypes]
  • [variableName, defaultValue, expectedDataTypes, expectedArrayCount]

variableName: String - name of a private variable (must begin with underscore _, e.g. "_myVar")
defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).
expectedDataTypes (Optional): Array of direct Data Types - checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.
expectedArrayCount (Optional): Number or Array - a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.
返回值:
Boolean - false if error occurred or default value has been used, otherwise true

替代句法

句法:
argument params [element1, element2,...elementN]
参数:
argument: Anything - A usual array of params is expected. If a non-array argument is passed, it will be converted to 1 element array

[element1, element2,...elementN]: Array - format array

elementN: String or Array:
If String then it is the name of a private variable (must begin with underscore _, e.g. "_myVar")
If Array then it should be one of the following constructs:

  • [variableName, defaultValue]
  • [variableName, defaultValue, expectedDataTypes]
  • [variableName, defaultValue, expectedDataTypes, expectedArrayCount]

variableName: String - name of a private variable (must begin with underscore _, e.g. "_myVar")
defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).
expectedDataTypes (Optional): Array of direct Data Types - checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.
expectedArrayCount (Optional): Number or Array - a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.
返回值:
Boolean - false if error occurred or default value has been used, otherwise true

范例

范例1:
[1, 2, 3] call { private ["_one", "_two", "_three"]; _one = _this select 0; _two = _this select 1; _three = _this select 2; // ..... };

// Same as above, only using params [1, 2, 3] call { params ["_one", "_two", "_three"]; // ..... };

范例2:
[123] call { params ["_myvar"]; };

// Below would produce the same result as above 123 call { params ["_myvar"]; };

范例3:
position player params ["", "", "_z"]; if (_z > 10) then { hint "YOU ARE FLYING!"; };

范例4:
[1, nil, 2] params ["_var1", "_var2", "_var3"]; // All 3 variables are made private but only _var1 and _var3 are defined

[1, nil, 2] params ["_var1", ["_var2", 23], "_var3"]; // All 3 variables are private and defined

范例5:
[1, 2] call { if (!params ["_var1", "_var2", ["_var3", true, [true]]]) exitWith { hint str [_var1, _var2, _var3]; }; }; // The hint shows [1,2,true] //Script exits, default value was used due to missing value

[1, 2, 3] call { if (!params ["_var1", "_var2", ["_var3", true, [true]]]) exitWith { hint str [_var1, _var2, _var3]; }; }; // The hint shows [1,2,true] //Script exits, default value was used due incorrect value type

范例6:
[1, "ok", [1, 2, 3]] call { if (!params [ ["_var1", 0, [0]], ["_var2", "", [""]], ["_var3", [0,0,0], [[], objNull, 0], [2,3]] ]) exitWith {}; hint "ok"; }; // Passes validation

[1, 2, [3, 4, 5]] call { if (!params ["_var1", "_var2", ["_var3", [], [[], objNull, 0], 0]]) exitWith {}; hint "ok"; }; // Fails, because passed array is expected to be of 0 length, i.e. empty

范例7:
position player params ["_x", "_y"]; player setPos [_x, _y, 100];

范例8:
[1, 2, 3, [4, 5, 6]] call { params ["_one", "_two", "_three"]; _this select 3 params ["_four", "_five", "_six"]; };

范例9:
{ _x params ["_group", "_index"]; // ..... } forEach waypoints group player;

fn_someFnc = { params ["_position", ["_direction", 0], ["_name", ""]]; // Extract the x, y, and z from "_position" array: _position params ["_x", "_y", "_z"]; // ..... };

[position player, direction player, name player] call fn_someFnc;

范例10:
targ addEventHandler ["HitPart", { _this select 0 params ["_target", "_shooter", "_projectile"]; }];

额外资讯

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

paramselectsetresizereverseinfindtoArraytoStringforEachcountdeleteAtdeleteRangeappendsortarrayIntersectsplitStringjoinStringisEqualTypeAllisEqualTypeisEqualTypeParamsisEqualTypeArrayisEqualTypeAnytypeNameBIS_fnc_param

注意事项

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

Posted on August 30, 2015 - 21:59 (UTC)
Killzone Kid
Because params doubles as private, instead of: [1, 2, 3] params ["_one", "_two", "_three"]; private "_four"; _four = 4; You can just:

[1, 2, 3] params ["_one", "_two", "_three", "_four"];

_four = 4;

更多维基

随机维基