sprucewaine 1 Posted July 17, 2019 I copied larrow's code and tried running it through this setup. halfWorldSize = (worldSize / 2); allLocations = nearestLocations [[halfWorldSize,halfWorldSize,0], ["NameVillage","HistoricalSite","NameCityCapital","NameCity"], halfWorldSize]; { _pos = locationPosition _x; //Create the sector logic _logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"]; //Default setting, which are optional _logic setVariable ["DefaultOwner","-1"]; _logic setVariable ["OnOwnerChange",""]; _logic setVariable ["OwnerLimit","0"]; _logic setVariable ["ScoreReward","0"]; _logic setVariable ["TaskOwner","3"]; //Set the sides for the sector _logic setVariable ["sides",[ east, west ]]; //Wait until sector is initialised waitUntil { !isNil { _logic getVariable [ "finalized", nil ] } && { !( _logic getVariable [ "finalized", true ] ) } }; //A size for the trigger _trgSize = 500; //Set the trigger size on the sector _logic setVariable [ "size", _trgSize ]; //Make the module update its trigger [ _logic, [], true, "area" ] call BIS_fnc_moduleSector; //Unfortunately the sector has not been written to also update its marker so.. //Get the modules trigger _trg = ( _logic getVariable "areas" ) select 0; //Get the triggers marker _mrk = ( _trg getVariable "markers" ) select 0; //Update the markers size _mrk setMarkerSize [ _trgSize, _trgSize ]; } forEach allLocations; But it only creates one sector. I don't know why its not working. More info on what I'm trying to do, i really like the idea of a scripted mission given how versatile it will be, just to drag the scripts over to any map. Once i get sectors on all the location spots, ill be trying to hook up the spawn ai modules. Share this post Link to post Share on other sites
sprucewaine 1 Posted July 17, 2019 Nvm i figured it out. Here is finished product. halfWorldSize = (worldSize / 2); allLocations = nearestLocations [[halfWorldSize,halfWorldSize,0], ["NameVillage","HistoricalSite","NameCityCapital","NameCity"], halfWorldSize]; { _pos = locationPosition _x; //Create the sector logic _logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"]; //Default setting, which are optional _logic setVariable ["DefaultOwner","-1"]; _logic setVariable ["OnOwnerChange",""]; _logic setVariable ["OwnerLimit","0"]; _logic setVariable ["ScoreReward","0"]; _logic setVariable ["TaskOwner","3"]; //Set the sides for the sector _logic setVariable ["sides",[ east, west ]]; //A size for the trigger _trgSize = 500; //Set the trigger size on the sector _logic setVariable [ "size", _trgSize ]; //Make the module update its trigger [_logic] call BIS_fnc_moduleSector; //Unfortunately the sector has not been written to also update its marker so.. //Get the modules trigger _trg = ( _logic getVariable "areas" ) select 0; //Get the triggers marker _mrk = ( _trg getVariable "markers" ) select 0; //Update the markers size _mrk setMarkerSize [ _trgSize, _trgSize ]; } forEach allLocations; Yeah i apologize deeply for just taking code like that, and not understanding it all that well. Share this post Link to post Share on other sites
Larrow 2820 Posted July 17, 2019 10 hours ago, sprucewaine said: [_logic] call BIS_fnc_moduleSector; Never recall the module initialisation. This is already done by the sector module itself. Spoiler _halfWorldSize = (worldSize / 2); _allLocations = nearestLocations [[ _halfWorldSize, _halfWorldSize,0], ["NameVillage","HistoricalSite","NameCityCapital","NameCity"], _halfWorldSize * 1.4142]; { _pos = locationPosition _x; //Create the sector logic "ModuleSector_F" createUnit [ _pos, createGroup sideLogic, " this setVariable[ 'DefaultOwner', '-1' ]; this setVariable[ 'OnOwnerChange', '' ]; this setVariable[ 'OwnerLimit', '0' ]; this setVariable[ 'ScoreReward', '0' ]; this setVariable[ 'TaskOwner', '3' ]; this setVariable[ 'sides', [ east, west ] ]; this setVariable[ 'BIS_fnc_initModules_disableAutoActivation', false, true ]; _nul = [ this ] spawn { params[ '_logic' ]; waitUntil { !isNil { _logic getVariable [ 'finalized', nil ] } && { !( _logic getVariable [ 'finalized', true ] ) } }; _trgSize = 500; _logic setVariable [ 'size', _trgSize ]; [ _logic, [], true, 'area' ] call BIS_fnc_moduleSector; _trg = ( _logic getVariable 'areas' ) select 0; _mrk = ( _trg getVariable 'markers' ) select 0; _mrk setMarkerSize [ _trgSize, _trgSize ]; }; " ]; } forEach _allLocations; 1 2 Share this post Link to post Share on other sites
sprucewaine 1 Posted July 17, 2019 I was not able to get that one to work, still only spawns one in the middle. "bis_o65 waiting" - the chat log, what ever that means. Share this post Link to post Share on other sites
Larrow 2820 Posted July 17, 2019 What map? I get 8 sectors on Stratis with those settings "NameVillage","HistoricalSite","NameCityCapital","NameCity". Ignore the "Waiting" thing it was in there as test code and I just forgot to remove it. Share this post Link to post Share on other sites
sprucewaine 1 Posted July 17, 2019 1 minute ago, Larrow said: What map? I get 8 sectors on Stratis with those settings "NameVillage","HistoricalSite","NameCityCapital","NameCity". Ignore the "Waiting" thing it was in there as test code and I just forgot to remove it. Gotcha, yeah ill try with other maps later, ATM i am doing the WW2 maps from iron front mod. I was going to be working with the base game maps and dlc maps eventually so, this will come in handy regardless. Thanks for the help. Share this post Link to post Share on other sites
sprucewaine 1 Posted July 18, 2019 Spoiler Upon retrying with a different map (stratis), i am still only getting one sector from your script. Would there be a mod that might affect anything? I got an ACE IF3 CBA setup. Spoiler On 7/17/2019 at 2:17 PM, Larrow said: Never recall the module initialisation. This is already done by the sector module itself. Reveal hidden contents _halfWorldSize = (worldSize / 2); _allLocations = nearestLocations [[ _halfWorldSize, _halfWorldSize,0], ["NameVillage","HistoricalSite","NameCityCapital","NameCity"], _halfWorldSize * 1.4142]; { _pos = locationPosition _x; //Create the sector logic "ModuleSector_F" createUnit [ _pos, createGroup sideLogic, " this setVariable[ 'DefaultOwner', '-1' ]; this setVariable[ 'OnOwnerChange', '' ]; this setVariable[ 'OwnerLimit', '0' ]; this setVariable[ 'ScoreReward', '0' ]; this setVariable[ 'TaskOwner', '3' ]; this setVariable[ 'sides', [ east, west ] ]; this setVariable[ 'BIS_fnc_initModules_disableAutoActivation', false, true ]; _nul = [ this ] spawn { params[ '_logic' ]; waitUntil { !isNil { _logic getVariable [ 'finalized', nil ] } && { !( _logic getVariable [ 'finalized', true ] ) } }; _trgSize = 500; _logic setVariable [ 'size', _trgSize ]; [ _logic, [], true, 'area' ] call BIS_fnc_moduleSector; _trg = ( _logic getVariable 'areas' ) select 0; _mrk = ( _trg getVariable 'markers' ) select 0; _mrk setMarkerSize [ _trgSize, _trgSize ]; }; " ]; } forEach _allLocations; Upon retrying with a different map (stratis), i am still only getting one sector from your script. Would there be a mod that might effect anything? I got an ACE IF3 CBA setup. Share this post Link to post Share on other sites
Larrow 2820 Posted July 19, 2019 17 hours ago, sprucewaine said: Would there be a mod that might effect anything? I got an ACE IF3 CBA setup. I do not know, that would be for you to test by removing all mods and re-enabling them one at a time to see what one effects it. As I said before the code in my previous post works fine for me on all vanilla maps. No mods loaded other than a few of my own Eden tools. Also this... On 7/17/2019 at 1:17 PM, Larrow said: this setVariable[ 'BIS_fnc_initModules_disableAutoActivation', false, true ]; ...is the answer to your other thread about spawning spawnAI module by script. When spawning any module in a running mission this is needed to make it initialise properly. 2 1 Share this post Link to post Share on other sites
BL4CK_SP1DER 1 Posted December 14, 2021 hello, 🙂 how do i make the ai capture sectors via script? Share this post Link to post Share on other sites
grrrrobots 0 Posted July 12, 2022 doesnt look like anyone actually answered this, private _logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"]; you need to add this to your loop to make the variable reset after each iteration of the foreach loop, thats why your only getting one sector, the variables in a foreach loop are local to that loop, so you can nest them fine, but to use the variable again each time in the same loop you need to reset its value for each time the loop executes wish i could have helped sooner, i cant see anything else wrong here really, but from your results thats sounds like where your having trouble Share this post Link to post Share on other sites
Harzach 2517 Posted July 12, 2022 35 minutes ago, grrrrobots said: but to use the variable again each time in the same loop you need to reset its value for each time the loop executes While privating local variables is always good practice, that's not what "private" does. Without it, "_logic" is still redefined in each iteration. You are also referring to abandoned code. See Larrow's first reply above. Share this post Link to post Share on other sites