Example Code: General Deletion: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Page creation) |
Lou Montana (talk | contribs) m (Fix code) |
||
Line 32: | Line 32: | ||
[[if]] ([[isNull]] _argument) [[exitWith]] { [[false]] }; | [[if]] ([[isNull]] _argument) [[exitWith]] { [[false]] }; | ||
[[if]] (_argument [[isEqualType]] [[objNull]]) [[exitWith]] {{cc|...the | [[if]] (_argument [[isEqualType]] [[objNull]]) [[exitWith]] {{cc|...the initial reason this function was written}} | ||
{ | { | ||
[[if]] ([[vehicle]] _x [[a == b|==]] _x) [[then]] | [[if]] ([[vehicle]] _x [[a == b|==]] _x) [[then]] | ||
Line 72: | Line 72: | ||
{ | { | ||
[[if]] (_parameter [[isEqualType]] 0) [[exitWith]] { [[deleteWaypoint]] [_argument, _parameter] }; | [[if]] (_parameter [[isEqualType]] 0) [[exitWith]] { [[deleteWaypoint]] [_argument, _parameter] }; | ||
[[units]] _argument [[call]] LM_fnc_delete; | [<nowiki/>[[units]] _argument [[call]]] LM_fnc_delete; | ||
[[deleteGroup]] _argument; | [[deleteGroup]] _argument; | ||
}; | }; |
Revision as of 19:16, 8 November 2020
fn_delete.sqf:
/* Author: Lou Montana Description: Deletes anything that is passed to it. Parameters: 0: OBJECT or GROUP or LOCATION or TEAM_MEMBER or ARRAY or SIDE or STRING or TASK 1: NUMBER or ARRAY or STRING Returns: NOTHING or NUMBER or BOOLEAN NOTHING NUMBER - deleteAt result BOOLEAN - false in case of null argument or no case met Examples: cursorObject call LM_fnc_delete group player call LM_fnc_delete [units group player] call LM_fnc_delete [["mark1", "mark2", "mark3"]] call LM_fnc_delete waypoints group player select 3 call LM_fnc_delete [myArray, 3] call LM_fnc_delete // myArray deleteAt 3 [myArray, [0, 3]] call LM_fnc_delete // myArray deleteRange [0, 3] */ params [ ["_argument", objNull, [objNull, grpNull, locationNull, teamMemberNull, [], ""]], ["_parameter", "", [0, [], ""]] ]; if (isNull _argument) exitWith { false }; if (_argument isEqualType objNull) exitWith // ...the initial reason this function was written { if (vehicle _x == _x) then { private _vehicle = _x; if !(crew _x isEqualTo []) then { { _vehicle deleteVehicleCrew _x } forEach crew _x; }; deleteVehicle _x; } else { objectParent _x deleteVehicleCrew _x; }; }; if (_argument isEqualType locationNull) exitWith { deleteLocation _argument }; if (_argument isEqualType teamMemberNull) exitWith { deleteTeam _argument }; if (_argument isEqualType []) exitWith { _argument params ["_item0", "_item1"]; if (_item1 isEqualType 0 && _item0 isEqualType grpNull) exitWith { deleteWaypoint [_item0, _item1] }; if (_item1 isEqualType 0 && _item0 isEqualType []) exitWith { _item0 deleteAt _item1 }; if (_item1 isEqualType [] && { count _item1 > 1 && _item1 isEqualTypeAll 0 }) exitWith { _item1 params ["_from", "_range"]; _item0 deleteRange [_from, _range]; }; { _x call LM_fnc_delete } forEach _argument; }; if (_argument isEqualType "") exitWith { if (_parameter isEqualType "" && { _parameter == "identity" }) exitWith { deleteIdentity _argument }; if (_parameter isEqualType "" && { _parameter == "status" }) exitWith { deleteStatus _argument }; if (_parameter isEqualType "" && { _parameter == "task" }) exitWith { [_argument, allUnits + allDeadMen] call BIS_fnc_deleteTask }; if (_parameter isEqualType "" && { _parameter == "local" }) exitWith { deleteMarkerLocal _argument }; deleteMarker _argument; }; if (_argument isEqualType grpNull) exitWith { if (_parameter isEqualType 0) exitWith { deleteWaypoint [_argument, _parameter] }; [units _argument call] LM_fnc_delete; deleteGroup _argument; }; if (_argument isEqualType blufor) exitWith { deleteCenter _argument }; if (_argument isEqualType taskNull && _parameter isEqualType objNull) exitWith { _parameter removeSimpleTask _argument }; false;