deleteWaypoint: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <nowiki>[</nowiki>" to " [<nowiki/>")
(Fix description and note)
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Removes the specified waypoint.<br><br>
| Removes the specified waypoint.
{{ Informative | When a waypoint is deleted, all other [[group]] [[waypoints]] are immediately re-indexed. So in order to delete all waypoints for a group, delete them from back to front:
{{Informative |
[[group]] _unit [[call]]
* When a waypoint is deleted, all other [[group]] [[waypoints]] are immediately re-indexed. See '''[[#Examples|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.}} |DESCRIPTION=
[[for]] "_i" [[from]] [[count]] [[waypoints]] [[_this]] - 1 [[to]] 0 [[step]] -1 [[do]]
{
[[deleteWaypoint]] [<nowiki/>[[_this]], _i];
};
};
}} |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| '''deleteWaypoint''' [group, index] |SYNTAX=
| [[deleteWaypoint]] [group, index] |SYNTAX=


|p1= [group, index]: [[Array]] |PARAMETER1=


|p1=  [group, index]: [[Array]] |PARAMETER1=
|p2=  group: [[Group]] |PARAMETER2=
|p2=  group: [[Group]] |PARAMETER2=
|p3= index: [[Number]] |PARAMETER3=
|p3= index: [[Number]] |PARAMETER3=


Line 33: Line 28:
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>[[deleteWaypoint]] [_grp, 2]</code> |EXAMPLE1=
|x1= <code>[[deleteWaypoint]] [_grp, 2];</code> |EXAMPLE1=
 
|x2= Because waypoints get immediately re-indexed when one gets deleted, delete them from last to first:
<code>[[private]] _group = [[group]] _unit;
[[for]] "_i" [[from]] [[count]] [[waypoints]] _group - 1 [[to]] 0 [[step]] -1 [[do]]
{
[[deleteWaypoint]] [_group, _i];
};</code> |EXAMPLE2=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[waypoints]], [[copyWaypoints]], [[setCurrentWaypoint]], [[setWaypointBehaviour]], [[setWaypointCombatMode]], [[setWaypointCompletionRadius]], [[setWaypointDescription]], [[setWaypointFormation]], [[setWaypointHousePosition]], [[setWaypointPosition]], [[setWaypointScript]], [[setWaypointSpeed]], [[setWaypointStatements]], [[setWaypointTimeout]], [[setWaypointType]], [[setWaypointVisible]], [[waypointAttachVehicle]], [[waypointAttachedVehicle]], [[setWaypointLoiterRadius]], [[waypointLoiterRadius]], [[addWaypoint]], [[setWaypointLoiterType]], [[waypointSpeed]] |SEEALSO=
| [[waypoints]], [[copyWaypoints]], [[setCurrentWaypoint]], [[setWaypointBehaviour]], [[setWaypointCombatMode]], [[setWaypointCompletionRadius]], [[setWaypointDescription]], [[setWaypointFormation]], [[setWaypointHousePosition]], [[setWaypointPosition]], [[setWaypointScript]], [[setWaypointSpeed]], [[setWaypointStatements]], [[setWaypointTimeout]], [[setWaypointType]], [[setWaypointVisible]], [[waypointAttachVehicle]], [[waypointAttachedVehicle]], [[setWaypointLoiterRadius]], [[waypointLoiterRadius]], [[addWaypoint]], [[setWaypointLoiterType]], [[waypointSpeed]] |SEEALSO=
}}
}}


Line 43: Line 44:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 1 Feb, 2008 - 07:48
<dd class="notedate">Posted on 1 Feb, 2008 - 07:48
<dt class="note">[[User:Saintolaf|Saintolaf]]
<dt class="note">[[User:Saintolaf|Saintolaf]]
<dd class="note">
<dd class="note">
In order to change the behavior of a unit currently following a string of waypoints, it is not enough to use deleteWaypoint. The path of the unit is calculated by the waypoints present at start, and the unit will continue according to the original waypoints even if you delete them by using this command.
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 units current position (thereby stopping the unit), and (after a small delay) use [[deleteWaypoint]] to remove the [[waypoints]].
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]].


<dd class="notedate">Posted on 15 Nov, 2008 - 13:37
<dd class="notedate">Posted on 15 Nov, 2008 - 13:37
<dt class="note">'''[[User:VictorFarbau|VictorFarbau]]'''
<dt class="note">[[User:VictorFarbau|VictorFarbau]]
<dd class="note">
<dd class="note">
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.
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"
<code>_combatGroup2 = [[createGroup]] EAST;
<code>_combatGroup2 = [[createGroup]] [[east]];
{[_x] [[joinSilent]] _combatGroup2} [[forEach]] ([[units]] _combatGroup);
{ [_x] [[joinSilent]] _combatGroup2 } [[forEach]] ([[units]] _combatGroup);
_combatGroup2 [[addWaypoint]] [ [[getPos]] [[player]], 25];</code>
_combatGroup2 [[addWaypoint]] [<nowiki/>[[getPos]] [[player]], 25];</code>


<dd class="notedate">Posted on January 04, 2011
<dt class="note">'''[[User:kju|kju]]'''
<dd class="note">
When you want to remove all waypoints, do '''NOT''' iterate over ''waypoints _group'' while trying to delete them (an array is by reference!). Instead use an approach like this:
<code>
[[while]] {([[count]] ([[waypoints]] _group)) > 0} [[do]]
{
  [[deleteWaypoint]] (([[waypoints]] _group) [[select]] 0);
};</code>
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>
Line 73: Line 65:
<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>


[[Category:Scripting Commands|DELETEWAYPOINT]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP Elite |DELETEWAYPOINT]]
[[Category:Scripting Commands OFP Elite |{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA|DELETEWAYPOINT]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Waypoints|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Waypoints|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
<!-- CONTINUE Notes -->
Line 86: Line 78:
<dt class="note">[[User:Mr H.|Mr H.]]</dt>
<dt class="note">[[User:Mr H.|Mr H.]]</dt>
<dd class="note">
<dd class="note">
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:


 
<code>[[group]] _unit [[spawn]]
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:
 
<code>group _unit spawn  
{
{
[_this,(currentWaypoint _this)] setWaypointPosition [getPosASL ((units _this) select 0), -1];
[_this, (currentWaypoint _this)] [[setWaypointPosition]] [<nowiki/>[[getPosASL]] (([[units]] _this) [[select]] 0), -1];
sleep 0.1;
[[sleep]] 0.1;
for "_i" from count waypoints _this - 1 to 0 step -1 do  
[[for]] "_i" from [[count]] [[waypoints]] [[_this]] - 1 [[to]] 0 [[step]] -1 [[do]]
{
{
deleteWaypoint [_this, _i];
[[deleteWaypoint]] [<nowiki/>[[_this]], _i];
};
};
};
};
</code>
</code>
Will stop the group where it is and delete its waypoints. 0.1 seems to be the correct sleep value in this case
Will stop the group where it is and delete its waypoints.
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 00:43, 6 April 2020

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Removes the specified waypoint.
  • When a waypoint is deleted, all other group waypoints are immediately re-indexed. See Example 2 for a deletion of all group's waypoints.
  • Deleting a group's current waypoint will not stop the group on its tracks.
Groups:
Uncategorised

Syntax

Syntax:
deleteWaypoint [group, index]
Parameters:
[group, index]: Array
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: private _group = group _unit; for "_i" from count waypoints _group - 1 to 0 step -1 do { deleteWaypoint [_group, _i]; };

Additional Information

See also:
waypointscopyWaypointssetCurrentWaypointsetWaypointBehavioursetWaypointCombatModesetWaypointCompletionRadiussetWaypointDescriptionsetWaypointFormationsetWaypointHousePositionsetWaypointPositionsetWaypointScriptsetWaypointSpeedsetWaypointStatementssetWaypointTimeoutsetWaypointTypesetWaypointVisiblewaypointAttachVehiclewaypointAttachedVehiclesetWaypointLoiterRadiuswaypointLoiterRadiusaddWaypointsetWaypointLoiterTypewaypointSpeed

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

Notes

Posted on 1 Feb, 2008 - 07:48
Saintolaf
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 15 Nov, 2008 - 13:37
VictorFarbau
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];

Bottom Section

Posted on November 17, 2019 - 16:52 (UTC)
Mr H.
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: group _unit spawn { [_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]; }; }; Will stop the group where it is and delete its waypoints.