Hallo Leute,
ich möchte für eine Funktion optionale Argumente ermöglichen, was soweit auch funktioniert.
Jetzt würde ich die Funktion allerdings gerne abändern, um stattdessen den param-Befehl zu nutzen, habe damit allerdings Probleme und würde mich über Hilfe freuen.
Hier erst einmal der funktionierende Code:
Code
- fnc_x = {
- private ["_array1","_array2","_unit","_param1a","_param1b","_param2a","_param2b"];
- _array1 = [];
- _array2 = [];
- _unit = _this select 0;
- _param1a = if (count _this > 1) then {_array1 pushback (_this select 2);};
- _param1b = if (count _this > 2) then {_array1 pushback (_this select 3);};
- _param2a = if (count _this > 3) then {_array2 pushback (_this select 4);};
- _param2b = if (count _this > 4) then {_array2 pushback (_this select 5);};
- ...
- };
Und das hier ist, was ich u.a. bisher probiert habe:
Wenn ich es so formuliere,
bin ich ja gezwungen, sämtliche Argumente anzugeben.
Die Funktion rufe ich über [this,[0,0,0],0,[0,0,0],0] call fnc_x; auf.
Danke und Grüße.
smile:)