deleteWaypoint: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) |
Lou Montana (talk | contribs) m (Add forEachReversed example) |
||
(33 intermediate revisions by the same user not shown) | |||
Line 27: | Line 27: | ||
|descr= Removes the specified waypoint. | |descr= Removes the specified waypoint. | ||
{{Feature|informative| | {{Feature|informative| | ||
* When a waypoint is deleted, all other [[group]] [[waypoints]] are immediately re-indexed. See {{ | * When a waypoint is deleted, all other [[group]] [[waypoints]] are immediately re-indexed. See {{Link|#Example 2}} for a deletion of all group's waypoints. | ||
* Deleting a group's [[currentWaypoint|current waypoint]] will ''not'' stop the group on its tracks. | * Deleting a group's [[currentWaypoint|current waypoint]] will ''not'' stop the group on its tracks. | ||
}} | }} | ||
Line 39: | Line 39: | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|x1= < | |x1= <sqf>deleteWaypoint [_grp, 2];</sqf> | ||
|x2= Because waypoints get immediately re-indexed when one gets deleted, delete them from last to first: | |x2= Because waypoints get immediately re-indexed when one gets deleted, delete them from last to first: | ||
< | <sqf> | ||
private _group = group _unit; | |||
for "_i" from (count waypoints _group - 1) to 0 step -1 do | |||
{ | { | ||
[ | deleteWaypoint [_group, _i]; | ||
};</ | }; | ||
</sqf> | |||
or always delete the first one (if you want to delete them all) | |||
<sqf> | |||
private _group = group _unit; | |||
for "_i" from 0 to (count waypoints _group - 1) do | |||
{ | |||
deleteWaypoint [_group, 0]; | |||
}; | |||
</sqf> | |||
or use [[forEachReversed]]: | |||
<sqf> | |||
{ deleteWaypoint _x } forEachReversed waypoints _group; // Arma 3 v2.14+ only | |||
</sqf> | |||
|seealso= [[waypoints | |seealso= [[waypoints]] [[setCurrentWaypoint]] [[setWaypointPosition]] [[setWaypointScript]] [[setWaypointStatements]] [[setWaypointType]] [[addWaypoint]] | ||
}} | }} | ||
Line 63: | Line 77: | ||
|text= Another (more foolproof) method to avoid the problem of non-deleteable waypoints is to introduce another group ([[createGroup]]) and [[join]] all units of the present group. A new group will start without any preset waypoints so you can start setting new WPs all over again. | |text= Another (more foolproof) method to avoid the problem of non-deleteable waypoints is to introduce another group ([[createGroup]]) and [[join]] all units of the present group. A new group will start without any preset waypoints so you can start setting new WPs all over again. | ||
Old group is "_combatGroup", new group is "_combatGroup2" | Old group is "_combatGroup", new group is "_combatGroup2" | ||
< | <sqf> | ||
{ [_x] | _combatGroup2 = createGroup east; | ||
_combatGroup2 | { [_x] joinSilent _combatGroup2 } forEach (units _combatGroup); | ||
_combatGroup2 addWaypoint [getPos player, 25]; | |||
</sqf> | |||
}} | }} | ||
Line 73: | Line 89: | ||
|text= To have the unit stop on the spot you need to set its current waypoint where it is and add a little delay, as stated above by [[User|Saintolaf]] so: | |text= To have the unit stop on the spot you need to set its current waypoint where it is and add a little delay, as stated above by [[User|Saintolaf]] so: | ||
< | <sqf> | ||
group _unit spawn | |||
{ | { | ||
[_this, | [_this, currentWaypoint _this] setWaypointPosition [getPosASL ((units _this) select 0), -1]; | ||
sleep 0.1; | |||
for "_i" from count waypoints _this - 1 to 0 step -1 do | |||
{ | { | ||
deleteWaypoint [_this, _i]; | |||
}; | }; | ||
}; | }; | ||
</ | </sqf> | ||
Will stop the group where it is and delete its waypoints. | Will stop the group where it is and delete its waypoints. | ||
}} | }} |
Latest revision as of 18:09, 27 April 2023
Description
- Description:
- Removes the specified waypoint.
- Groups:
- Waypoints
Syntax
- Syntax:
- deleteWaypoint [group, index]
- Parameters:
- group: Group
- index: Number
- Return Value:
- Nothing
Examples
- Example 1:
- deleteWaypoint [_grp, 2];
- Example 2:
- Because waypoints get immediately re-indexed when one gets deleted, delete them from last to first:
or always delete the first one (if you want to delete them all)or use forEachReversed:
Additional Information
- See also:
- waypoints setCurrentWaypoint setWaypointPosition setWaypointScript setWaypointStatements setWaypointType addWaypoint
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
- Posted on Jan 01, 2008 - 07:48 (UTC)
- In order to change the behavior of a unit currently following some waypoints, it is not enough to use deleteWaypoint. To achieve the wanted effect, you should rather use setWPPos to the unit's current position (thereby stopping the unit), and (after a small delay) use deleteWaypoint to remove the next waypoints.
- Posted on Nov 15, 2008 - 13:37 (UTC)
-
Another (more foolproof) method to avoid the problem of non-deleteable waypoints is to introduce another group (createGroup) and join all units of the present group. A new group will start without any preset waypoints so you can start setting new WPs all over again.
Old group is "_combatGroup", new group is "_combatGroup2"
_combatGroup2 = createGroup east; { [_x] joinSilent _combatGroup2 } forEach (units _combatGroup); _combatGroup2 addWaypoint [getPos player, 25];
- Posted on Nov 17, 2019 - 16:52 (UTC)
- To have the unit stop on the spot you need to set its current waypoint where it is and add a little delay, as stated above by Saintolaf so: Will stop the group where it is and delete its waypoints.
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint: Elite version 1.00
- Operation Flashpoint: Elite: New Scripting Commands
- Operation Flashpoint: Elite: Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Waypoints
- Scripting Commands: Global Effect