Example Code: General Deletion: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Fix _x → _argument) |
Lou Montana (talk | contribs) m (Fix check) |
||
Line 28: | Line 28: | ||
]; | ]; | ||
[[if]] ([[isNull]] _argument) [[exitWith]] { [[false]] }; | [[if]] (!(_argument [[isEqualType]] []) && { [[isNull]] _argument }) [[exitWith]] { [[false]] }; | ||
[[if]] (_argument [[isEqualType]] [[objNull]]) [[exitWith]] {{cc|...the initial reason this function was written}} | [[if]] (_argument [[isEqualType]] [[objNull]]) [[exitWith]] {{cc|...the initial reason this function was written}} | ||
{ | { |
Revision as of 19:34, 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: ANYTHING 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 (!(_argument isEqualType []) && { isNull _argument }) exitWith { false }; if (_argument isEqualType objNull) exitWith // ...the initial reason this function was written { if (vehicle _argument == _argument) then { private _vehicle = _argument; if !(crew _argument isEqualTo []) then { { _argument deleteVehicleCrew _x } forEach crew _argument; }; deleteVehicle _argument; } else { objectParent _argument deleteVehicleCrew _argument; }; }; 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;