Jump to content
Sign in to follow this  
RS30002

Script loop issue

Recommended Posts

yoyo, so ive made a little ambient forager script, walk around some fields, do some animations, walk some more to another forage spot and repeat.

 

the issue is if i type it out so that the last waypoint is a cycle, when the forager starts his 2nd pass, he doesn't do any animations, just continues to walk from spot to spot (where he was supposed to do animations)

 

if i put the whole script into a "while true do" loop, nothing of note happens and if i put the last waypoint as a "move" (because the script is supposed to handle the cycle) he stops at the last waypoint (the script doesnt handle the cycle lol).

 

The guy also seems to loose his hat and backpack everytime the animations are performed....

 

ty for any suggestions, bb

 

 

while {alive forager} do {

_frgwp1 = foragergrp addWaypoint [(getpos wheat1), 0];
_frgwp1 setWaypointType "MOVE";
_frgwp1 setWaypointSpeed "LIMITED";
waitUntil {sleep 0.5;((forager distance wheat1) <= 1)};
[forager, "KNEEL_TREAT", "NONE"] call BIS_fnc_ambientAnim;
sleep 10;
forager call BIS_fnc_ambientAnim__terminate;
forager addheadgear "vn_c_conehat_02";
forager addbackpack "vn_c_pack_01";


_frgwp2 = foragergrp addWaypoint [(getpos wheat2), 0];
_frgwp2 setWaypointType "MOVE";
_frgwp2 setWaypointSpeed "LIMITED";
waitUntil {sleep 0.5;((forager distance wheat2) <= 1)};
[forager, "REPAIR_VEH_KNEEL", "NONE"] call BIS_fnc_ambientAnim;
sleep 10;
forager call BIS_fnc_ambientAnim__terminate;
forager addheadgear "vn_c_conehat_02";
forager addbackpack "vn_c_pack_01";

_frgwp6 = foragergrp addWaypoint [(getpos rice3), 0];
_frgwp6 setWaypointType "MOVE";
_frgwp6 setWaypointSpeed "LIMITED";
waitUntil {sleep 0.5;((forager distance rice3) <= 1.2)};
[forager, "KNEEL_TREAT", "NONE"] call BIS_fnc_ambientAnim;
sleep 10;
forager call BIS_fnc_ambientAnim__terminate;
forager addheadgear "vn_c_conehat_02";
forager addbackpack "vn_c_pack_01";


_frgwp7 = foragergrp addWaypoint [(getpos wheat3), 0];
_frgwp7 setWaypointType "MOVE";
_frgwp7 setWaypointSpeed "LIMITED";
waitUntil {sleep 0.5;((forager distance wheat3) <= 1)};
[forager, "KNEEL_TREAT", "NONE"] call BIS_fnc_ambientAnim;
sleep 10;
forager call BIS_fnc_ambientAnim__terminate;
forager addheadgear "vn_c_conehat_02";
forager addbackpack "vn_c_pack_01";


};

 

Share this post


Link to post
Share on other sites

Use setWaypointStatements:

_frgwp1 = foragergrp addWaypoint [(getpos wheat1), 0];
_frgwp1 setWaypointType "MOVE";
_frgwp1 setWaypointSpeed "LIMITED";
_frgwp1 setWaypointStatements [
	"true",
	"0 = [] spawn {
		waitUntil {sleep 0.5;((forager distance wheat1) <= 1)};
		[forager, 'KNEEL_TREAT', 'NONE'] call BIS_fnc_ambientAnim;
		sleep 10;
		forager call BIS_fnc_ambientAnim__terminate;
		forager addheadgear 'vn_c_conehat_02';
		forager addbackpack 'vn_c_pack_01';
	};"
];

Pay close attention to syntax here, particularly where quotation marks are used. The statements are strings, so any strings within them must use single quotes.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

Use setWaypointStatements:


_frgwp1 = foragergrp addWaypoint [(getpos wheat1), 0];
_frgwp1 setWaypointType "MOVE";
_frgwp1 setWaypointSpeed "LIMITED";
_frgwp1 setWaypointStatements [
	"true",
	"0 = spawn [] {
		waitUntil {sleep 0.5;((forager distance wheat1) <= 1)};
		[forager, 'KNEEL_TREAT', 'NONE'] call BIS_fnc_ambientAnim;
		sleep 10;
		forager call BIS_fnc_ambientAnim__terminate;
		forager addheadgear 'vn_c_conehat_02';
		forager addbackpack 'vn_c_pack_01';
	};"
];

Pay close attention to syntax here, particularly where quotation marks are used. The statements are strings, so any strings within them must use single quotes.

 

 

hey, ty for the reply, gives out an error that idk how to tackle, it wants a ; after the {    ?

 

fdfdfdf.jpg

Share this post


Link to post
Share on other sites

Sorry, typo on my part, fixed in my previous post.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

Sorry, typo on my part, fixed in my previous post.

 

Ya, it's working now. Many thanks! :wine:

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  

×