zodd 14 Posted September 15, 2013 Gday all, I am running the following script to set a waypoint: AddWaypoint.sqf _groupToAdd = _this select 0; _waypointLocation = _this select 1; _wp = _groupToAdd addWaypoint [_waypointLocation, 0]; _wp setWaypointStatements ["true", "_groupToAdd setVariable ['FinishedMoving', true]; hint 'Finshed now'"]; _wp setWaypointType "MOVE"; I get the Finished now hint but when I check the finished moving variable it is still false. Extract of script calling the function: _groupToWaypoint = commanderOneSubordinateGroups select 0; _wpLoc = _groupToWaypoint getVariable "MoveMarker"; _groupToWaypoint setVariable ["FinishedMoving", false]; _wpX = (_mainWaypointLoc select 0) + 60; _wpY = (_mainWaypointLoc select 1) + 50; _wpLoc setMarkerPos [_wpX, _wpY]; _waypointLoc = getMarkerPos _wpLoc; nul = [_groupToWaypoint, _waypointLoc] execVM "AddWaypoint.sqf"; Any thoughts on why this isnt working and how I can get it to function? Cheers all! Share this post Link to post Share on other sites
f2k sel 164 Posted September 15, 2013 You can't use the local variable _groupToAdd within setWaypointStatements remove the underscore _ Share this post Link to post Share on other sites
Larrow 2822 Posted September 15, 2013 As F2k Sel said you cant use a local variable in the setWaypointStatements as when run the waypoints statement is not in the same scope as the script so it wont know what _groupToAdd is. Either use a global varaible e.g as Sel said remove the _ from the variables name or Compile the variable into the statement e.g call compile format ["_wp setWaypointStatements [""true"", ""%1 setVariable ['FinishedMoving', true]; hint 'Finshed now'""]", _groupToAdd]; Share this post Link to post Share on other sites
zodd 14 Posted September 16, 2013 The issue with a global variable is I don't know which unit it will be for; it is a commander script that assigns waypoints dynamically. I need a way of tracking when a unit is moving and when it has completed the waypoint. I tried the call compile but couldn't get it to work.... no joy with the example above or any of my tinkering. Will try a bit more when I get a chance but open to other ideas too! Thanks again! Share this post Link to post Share on other sites
mr_centipede 31 Posted September 16, 2013 Here's what I'd do: _wp setWaypointStatements ["true", "(group this) setVariable ['FinishedMoving', true]; hint 'Finshed now'"]; bolded part is mine. Hope it works Share this post Link to post Share on other sites
zodd 14 Posted September 19, 2013 No joy with the group this because the script is being called from a different unit (Commander unit assigning waypoints to subordinate units) Share this post Link to post Share on other sites
k0rd 3 Posted September 19, 2013 (edited) @zodd - you could use a waypoint script when it has completed the previous waypoint to notify when the waypoint is finished. _wpB = _groupToAdd addWaypoint [_waypointLocation, 0]; _wpB setWaypointType "SCRIPTED"; _wpB setWaypointScript "ScriptToDoAfterGroupHasReachedPreviousWaypoint.sqf"; waypointlocation doesn't matter in this case, it will auto-execute the .sqf once the previous waypoint (_wp i assume) has completed. (edit) An argument array is passed to the script in the form [<group leader>,<waypoint position array>,<object waypoint is attached to>,<user array element 0>,<user array element 1>,<user array element 3>,<user array element 4>]. so you can get the leader with _this select 1, or whatever (double edit) you should take _wp setWaypointStatements out of your original waypoint Edited September 19, 2013 by k0rd clarification Share this post Link to post Share on other sites
mr_centipede 31 Posted September 19, 2013 No joy with the group this because the script is being called from a different unit (Commander unit assigning waypoints to subordinate units) It should not matter, the setVariable is assigned to the group that is going to the waypoint: eg, grp1 setVariable ["myVariable", 1, true]; grp2 setVariable ["myVariable", 2, true]; so if you getVariable: grp1 getVariable "myVariable" should return 1 and grp2 getVariable "myVariable" should return 2. With that said, how do you check the 'FinishedMoving' variable? Share this post Link to post Share on other sites
zodd 14 Posted September 19, 2013 Cent - Apologies, I looked at it quickly without considering it (or testing it) - My bad, it actually works perfectly! So good... thanks so much! Checking finished moving with repeatable radio trigger hint. Kord - Thanks for your input - Not needed at the moment for this case but I think it would definitely be beneficial for other aspects that I am planning. Thanks again all - much appreciated! Share this post Link to post Share on other sites
k0rd 3 Posted September 19, 2013 cool man, glad you got it working :) Share this post Link to post Share on other sites
mr_centipede 31 Posted September 20, 2013 Glad it works. In case you didn't know, 'this' in waypoint's act field refers to the group leader that completes the waypoint and 'thisList' refer the all units in that particular group. That's why I use 'group this' Share this post Link to post Share on other sites