Jump to content
Sign in to follow this  
borg117

Creating waypoints, deleting them and creating new waypoints (scripting)

Recommended Posts

Ok i've been doing a trial and error with this for some time and with most things i figure it out but not with this.

I am creating a heli taxi script via fsm which enables a player to call for heli via onMapSingleClick command, that command creates a set of waypoints which configured, allow the heli to land, pick up, drop off and return to base.

It all works brilliantly except that when i call the transport again, (and i have narrowed this problem down i assure you) it doesn't seem to follow the waypoints through.

waypoint1 = _grp addwaypoint [_pos, 0];

waypoint1 setwaypointtype "MOVE";

waypoint1 setWaypointStatements ["","doStop _veh; _veh land ""GET IN"""];

this is what the general format of my waypoints are, there are 4 in total, 2 for the pick 2 for the drop off. as i have said they work just fine the first time, but not the second time. the entire FSM is interlaced in various radio chatter and other commands which work fine, i've used hints to test FSM flow, its all fine its just to do with those waypoints. i've localizing 'waypoint1' or replacing it with 'nul', just in case there is a problem with re-iteration. in addition i would note that i do use deletewaypoint as thus:

deleteWaypoint [_grp, 0]; deleteWaypoint [_grp, 1]; deleteWaypoint [_grp, 2]; deleteWaypoint [_grp, 3];

Help would very much be appreciated, in my many searches i found this:

http://www.kylania.com/ex/?p=47

Which relates slightly to my issue as my procedures are incredibly similar, the difference is, my script relies on 'an already spawned, and undeleted' heli, as opposed to Kylania which is spawned, hence he wouldn't have a problem with reiteration of waypoints.

Share this post


Link to post
Share on other sites

I wonder a little about the way you delete waypoints. It should be correct if you deleted them in the opposite order, but now you delete the first one, then the second waypoint (with index 1) gets index 0, so you never actually delete that waypoint. Instead, second delete command deletes the third waypoint which now has index 2 (and so on). Putting index 0 in all delete commands will maybe solve the problem. Or not deleting them at all...

Share this post


Link to post
Share on other sites

while {(count (waypoints _group)) > 0} do
{
deleteWaypoint ((waypoints _group) select 0);
};

From kju on the wiki page for deleteWaypoint

Share this post


Link to post
Share on other sites

Thank you so much, will test it when i get home but I never once thought of that Engima and thanks Kylania for pointing that out. will start to look at the wiki more because I always look at the comref and never thought of comments :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×