lordfrith 402 Posted October 11, 2018 (edited) hi folks i've written a while loop to scan for nearby buildings as player moves around. on mission load everything is working beautifully but on loading a save game the loop doesn't continue. the structure of the loop being spawned is as follows, in the mission init there is: Quote [param,param,param]call compile preprocessFile "LF_Init.sqf"; which has a bunch of variable/function defines and then at the bottom: Quote if (isServer) then { sleep 1; _start = [param,param,param] execVM "LF_loop.sqf" }; which contains the while loop: Quote /////////////////////////lOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP//// params ["param","param","param"]; sleep 1; while{true}do{ _call = [params] call LF_fnc_stuffAndThings; etc; sleep 1; }; is there anythings obviously wrong with the scheduled/unscheduled environment thing here? I'm a bit hazy on it still... i thought when the save is loaded the while loop state would be loaded and continue Edited October 11, 2018 by lordfrith Share this post Link to post Share on other sites
cb65 86 Posted October 12, 2018 This was an interesting read from arma 2OA and might be able to help you. May not apply to arma 3. https://forums.bohemia.net/forums/topic/103016-scripts-dont-work-after-savereload/ 2 Share this post Link to post Share on other sites
Dedmen 2724 Posted October 12, 2018 do you have "disableSerialization" anywhere? 1 Share this post Link to post Share on other sites
lordfrith 402 Posted October 12, 2018 2 hours ago, Dedmen said: do you have "disableSerialization" anywhere? i don't think so, save/load seems to work ok for other stuff, this is defined in description.ext right? i'll check in the editor settings too, i wouldn't have it in any of my scripts as being save compatible is a big part of what i'm trying to do. as seen in my example above there are unscheduled function calls within the while loop, would this be causing it? once you've run something in a scheduled environment does everything within that function also have to be unscheduled? 7 hours ago, cb65 said: interesting read from arma 2OA and might be able to help you. cheers, i was actually reading that very thread looking for answers. When AZcoder says: Quote The state of this thread gets saved with the mission, so when you reload, the thread keeps running. When you load from a save, the last sleep command will still run, thats what made me believe it was possible... thanks for your answers folks :D P.S. as a test i removed the while loop and just spawned the function again as it ends, this works ok with save load so i've botched it to work but would be nice to figure out this while loop thing... EDIT : can anyone think of a bomb proof example of a save proof while loop i could have a look at? i've been checking through other scripts i have but not found an obvious good example Share this post Link to post Share on other sites
Dedmen 2724 Posted October 12, 2018 5 minutes ago, lordfrith said: this is defined in description.ext right No https://community.bistudio.com/wiki/disableSerialization That script command executed in your script or any script you "call" 5 minutes ago, lordfrith said: as seen in my example above there are unscheduled function calls within the while loop, would this be causing it? What are "unscheduled function calls" ? Your script is scheduled. 5 minutes ago, lordfrith said: once you've run something in a scheduled environment does everything within that function also have to be unscheduled? What? Scheduled code runs scheduled. I don't understand what you mean. Might wanna read this? https://community.bistudio.com/wiki/Scheduler Share this post Link to post Share on other sites
lordfrith 402 Posted October 12, 2018 2 minutes ago, Dedmen said: I don't understand what you mean. sorry dude, i have no background in this stuff so i find it real hard to describe what i'm trying to do correctly, getting this far has been a bit of a journey ;) i have read the page you linked before and.... soooort of understood it 4 minutes ago, Dedmen said: What are "unscheduled function calls" ? Your script is scheduled. so the script is scheduled as its execVM... but within that i'm using unscheduled 'call' to start other functions... this isn't an issue then? Share this post Link to post Share on other sites
Dedmen 2724 Posted October 12, 2018 18 minutes ago, lordfrith said: unscheduled 'call' "call" is not unscheduled. it doesn't change the scheduled-ness. A call inside unscheduled stays unscheduled. A call inside scheduled stays scheduled. Only issue I can think of is you having disableSerialization somewhere. Share this post Link to post Share on other sites
lordfrith 402 Posted October 12, 2018 32 minutes ago, Dedmen said: Only issue I can think of is you having disableSerialization somewhere. hmm well i don't but i think given our discussion above i need to go back and relearn a bunch of stuff anyways, thanks for your helps, if i get this sorted i'll post back here Share this post Link to post Share on other sites
lordfrith 402 Posted October 12, 2018 SOLVED: switching the functions in the while loop from 'call' to 'spawn' seems to allow saving and loading to work as intended i.e. Quote /////////////////////////lOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP////LOOP//// params ["param","param","param"]; sleep 1; while{true}do{ _spawn = [params] spawn LF_fnc_stuffAndThings; etc; sleep 1; }; 1 Share this post Link to post Share on other sites
lordfrith 402 Posted October 12, 2018 @Dedmen yeah i'm confused too given what you've just told me Share this post Link to post Share on other sites