Lucky44 13 Posted May 15, 2011 (edited) I know I'm missing something simple, but I can't see why it's not working. the problematic line is this: _spwn = _spawnSet select _spawnroll; I keep getting stuck on that line. If I substitute the literal array name (_SP1) for the variable _spawnSet, like this: //_spwn = _SP1 select _spawnroll; it works fine. (There's a comment below with that line.) And that is in the context of the follow code. I'll put a longer explanation following the code, for those that want it. _spwnPt = ["nul","_SP1","_SP2","_SP3","_SP4","_SP5","_SP6","_SP7","_SP8","_SP9","_SP10","_SP11","_SP12","_SP13","_SP14","_SP15","_SP16","_SP17","_SP18","_SP19","_SP20","_SP21","_SP22","_SP23","_SP24"]; _WPt = ["_WPt1","_WPt2","_WPt3","_WPt4","_WPt5","_WPt6","_WPt7","_WPt8","_WPt9","_WPt10","_WPt11","_WPt12","_WPt13","_WPt14","_WPt15","_WPt16","_WPt17","_WPt18","_WPt19","_WPt20","_WPt21","_WPt22","_WPt23","_WPt24"]; // Starting with the first 8 trigger areas for now...will add up to 16 more later, if needed. _SP1 = ["spwn1a","spwn1b","spwn1c","spwn1d","spwn1e","spwn1f","spwn1g","spwn1h","spwn1i","spwn1j"]; _SP2 = ["spwn2a","spwn2b","spwn2c","spwn2d","spwn2e","spwn2f","spwn2g","spwn2h","spwn2i","spwn2j"]; _SP3 = ["spwn3a","spwn3b","spwn3c","spwn3d","spwn3e","spwn3f","spwn3g","spwn3h","spwn3i","spwn3j"]; _SP4 = ["spwn4a","spwn4b","spwn4c","spwn4d","spwn4e","spwn4f","spwn4g","spwn4h","spwn4i","spwn4j"]; _SP5 = ["spwn5a","spwn5b","spwn5c","spwn5d","spwn5e","spwn5f","spwn5g","spwn5h","spwn5i","spwn5j"]; _SP6 = ["spwn6a","spwn6b","spwn6c","spwn6d","spwn6e","spwn6f","spwn6g","spwn6h","spwn6i","spwn6j"]; _SP7 = ["spwn7a","spwn7b","spwn7c","spwn7d","spwn7e","spwn7f","spwn7g","spwn7h","spwn7i","spwn7j"]; _SP8 = ["spwn8a","spwn8b","spwn8c","spwn8d","spwn8e","spwn8f","spwn8g","spwn8h","spwn8i","spwn8j"]; _WPt1 = ["WP1a","WP1b","WP1c","WP1d","WP1e","WP1f","WP1g","WP1h","WP1i","WP1j"]; _WPt2 = ["WP2a","WP2b","WP2c","WP2d","WP2e","WP2f","WP2g","WP2h","WP2i","WP2j"]; _WPt3 = ["WP3a","WP3b","WP3c","WP3d","WP3e","WP3f","WP3g","WP3h","WP3i","WP3j"]; _WPt4 = ["WP4a","WP4b","WP4c","WP4d","WP4e","WP4f","WP4g","WP4h","WP4i","WP4j"]; _WPt5 = ["WP5a","WP5b","WP5c","WP5d","WP5e","WP5f","WP5g","WP5h","WP5i","WP5j"]; _WPt6 = ["WP6a","WP6b","WP6c","WP6d","WP6e","WP6f","WP6g","WP6h","WP6i","WP6j"]; _WPt7 = ["WP7a","WP7b","WP7c","WP7d","WP7e","WP7f","WP7g","WP7h","WP7i","WP7j"]; _WPt8 = ["WP8a","WP8b","WP8c","WP8d","WP8e","WP8f","WP8g","WP8h","WP8i","WP8j"]; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _rand1 = random 1; hint format ["The random chance is %1",_rand1]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! if (_rand1 <= 0.6) then { _spawnSet = _spwnPt select trigger; // pick the array of possible spawn points for the right trigger area; "trigger" is a global variable determined in the on-map trigger hint format ["_spawnSet is now %1",_spawnSet]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _spawnroll = floor(random 10); // so that it can randomly pick 1 of the 10 possible spawn points for the group... hint format ["_spawnroll is now %1",_spawnroll]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _spwn = _spawnSet select _spawnroll; // use _spawnroll to randomly pick one of the 10 spawn points //_spwn = _SP1 select _spawnroll; // testing by forcing the _spawnSet to _SP1 hint format ["The chosen spawn point is %1",_spwn]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _SpawnGrp = createGroup RESISTANCE; _SpawnGrp = [getMarkerPos _spwn, RESISTANCE, 9,[],[], [1,1,1]] call BIS_fnc_spawnGroup; // spawn a basic (random) group, then add the units below }; // end of big if section EXPLANATION: There will be roughly 24 trigger "areas" on the map, and a 60% chance that each one will spawn enemies. At each trigger area, there are 10 possible spawn points, and each group that spawns will spawn at a randomly chosen point from within the 10 possible. (There's some code there about waypoints they'll use, but that's not relevant yet.) Everything runs fine (as the debug hints show) until the troublesome line. (And as I said, if I substitute _SP1 for _spawnSet in the bad line, the whole thing works right. But that only works for the one trigger location, and I want the same script to work for all 24 trigger locations.) Thanks! Edited May 15, 2011 by Lucky44 Share this post Link to post Share on other sites
demonized 20 Posted May 15, 2011 (edited) spawnSet = _spwnPt select trigger; i asume this is the issue, you use trigger, but trigger is nowhere to be found in script. Edit: also it was spawnset not _spawnset before, see you have corrected it or my eyes have fooled me... Edited May 15, 2011 by Demonized Share this post Link to post Share on other sites
Lucky44 13 Posted May 15, 2011 Sorry, Demonized. I had tried making some variables Global and local, but it makes no difference in this situation. So it should be all local variables, except trigger, which is set in the on-map trigger, as I added in an edit. ALSO: The error that is showing via Show Script Errors is "Error select: Type string, expected Array,Config entry" - so the problem is something to do with how I'm using _spawnSet in the line _spawnSet select _spawnroll; I tried making it _spwn = (_spwnPt select trigger) select _spawnroll; but that didn't help at all; it DID make the error message different, though. Share this post Link to post Share on other sites
demonized 20 Posted May 15, 2011 well, i asume you know that select needs an array to pick from?? also that the way its setup trigger needs to be a number inside the count of the array. You are selecting probably selecting from a "triggername" instead of a ["triggername"] Else i suspect trigger being the problem, either not declared before script starts, or wrong type(not number) anyhow, check your arrays and select numbers. Share this post Link to post Share on other sites
Lucky44 13 Posted May 15, 2011 Hmm. Yes, I know that Select needs an array. And yes, trigger is a number. In my current tests, it's always 1. These lines work fine: _spawnSet = _spwnPt select trigger; // pick the array of possible spawn points for the right trigger area; "trigger" is a global variable determined in the on-map trigger hint format ["_spawnSet is now %1",_spawnSet]; and show that the script is picking the 2nd element of the array _spwnPt properly. The trouble comes when it tries to use that element, "_SP1", as an array itself soon after. I fear it's trying to use it as a string rather than the array name. But I'm not sure how to change that. I tried changing the array _SP1 from ["spwn1a","spwn1b",etc] to [spwn1a,spwn1b,etc] but that didn't work. The arrays are all shown. I don't see a problem with them; do you? Share this post Link to post Share on other sites
demonized 20 Posted May 15, 2011 (edited) i see now, you declare the array before actually declaring the arrays: _spwnPt = ["nul","_SP1","_SP2","_SP3","_SP4","_SP5","_SP6","_SP7","_SP8","_SP9","_SP10","_SP11","_SP12","_SP13","_SP14","_SP15","_SP16","_SP17","_SP18","_SP19","_SP20","_SP21","_SP22","_SP23","_SP24"]; change that to _spwnPT = [nul, _SP1, etc]; no qoutes around. and add the line after _WPt8 array before _rand1 = random 1; do same for _WPt array as well. // Starting with the first 8 trigger areas for now...will add up to 16 more later, if needed. _SP1 = ["spwn1a","spwn1b","spwn1c","spwn1d","spwn1e","spwn1f","spwn1g","spwn1h","spwn1i","spwn1j"]; _SP2 = ["spwn2a","spwn2b","spwn2c","spwn2d","spwn2e","spwn2f","spwn2g","spwn2h","spwn2i","spwn2j"]; _SP3 = ["spwn3a","spwn3b","spwn3c","spwn3d","spwn3e","spwn3f","spwn3g","spwn3h","spwn3i","spwn3j"]; _SP4 = ["spwn4a","spwn4b","spwn4c","spwn4d","spwn4e","spwn4f","spwn4g","spwn4h","spwn4i","spwn4j"]; _SP5 = ["spwn5a","spwn5b","spwn5c","spwn5d","spwn5e","spwn5f","spwn5g","spwn5h","spwn5i","spwn5j"]; _SP6 = ["spwn6a","spwn6b","spwn6c","spwn6d","spwn6e","spwn6f","spwn6g","spwn6h","spwn6i","spwn6j"]; _SP7 = ["spwn7a","spwn7b","spwn7c","spwn7d","spwn7e","spwn7f","spwn7g","spwn7h","spwn7i","spwn7j"]; _SP8 = ["spwn8a","spwn8b","spwn8c","spwn8d","spwn8e","spwn8f","spwn8g","spwn8h","spwn8i","spwn8j"]; _WPt1 = ["WP1a","WP1b","WP1c","WP1d","WP1e","WP1f","WP1g","WP1h","WP1i","WP1j"]; _WPt2 = ["WP2a","WP2b","WP2c","WP2d","WP2e","WP2f","WP2g","WP2h","WP2i","WP2j"]; _WPt3 = ["WP3a","WP3b","WP3c","WP3d","WP3e","WP3f","WP3g","WP3h","WP3i","WP3j"]; _WPt4 = ["WP4a","WP4b","WP4c","WP4d","WP4e","WP4f","WP4g","WP4h","WP4i","WP4j"]; _WPt5 = ["WP5a","WP5b","WP5c","WP5d","WP5e","WP5f","WP5g","WP5h","WP5i","WP5j"]; _WPt6 = ["WP6a","WP6b","WP6c","WP6d","WP6e","WP6f","WP6g","WP6h","WP6i","WP6j"]; _WPt7 = ["WP7a","WP7b","WP7c","WP7d","WP7e","WP7f","WP7g","WP7h","WP7i","WP7j"]; _WPt8 = ["WP8a","WP8b","WP8c","WP8d","WP8e","WP8f","WP8g","WP8h","WP8i","WP8j"]; _spwnPt = [nul,_SP1,_SP2,etc]; _WPt = [_WPt1,_WPt2,etc]; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _rand1 = random 1; hint format ["The random chance is %1",_rand1]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! if (_rand1 <= 0.6) then { _spawnSet = _spwnPt select trigger; // pick the array of possible spawn points for the right trigger area; "trigger" is a global variable determined in the on-map trigger hint format ["_spawnSet is now %1",_spawnSet]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _spawnroll = floor(random 10); // so that it can randomly pick 1 of the 10 possible spawn points for the group... hint format ["_spawnroll is now %1",_spawnroll]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _spwn = _spawnSet select _spawnroll; // use _spawnroll to randomly pick one of the 10 spawn points //_spwn = _SP1 select _spawnroll; // testing by forcing the _spawnSet to _SP1 hint format ["The chosen spawn point is %1",_spwn]; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! sleep 3; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!! _SpawnGrp = createGroup RESISTANCE; _SpawnGrp = [getMarkerPos _spwn, RESISTANCE, 9,[],[], [1,1,1]] call BIS_fnc_spawnGroup; // spawn a basic (random) group, then add the units below }; // end of big if section Edited May 15, 2011 by Demonized Share this post Link to post Share on other sites
Lucky44 13 Posted May 15, 2011 @Demonized: Aha! Thanks for your time and effort. I had the feeling it was something I just wasn't seeing. -I didn't realize that the order had to be like that, but it makes sense now. Cheers. Share this post Link to post Share on other sites