I am trying to get a looping system to remove the selected Masterarray element when it's subarray is empty
The following system is a simplified version of the actual system showing only the pertinent information
INIT.sqs
;;;Sub Arrays
tx_AmbushArray = ["Missions\AmbushA.sqs","Missions\AmbushB.sqs","Missions\AmbushC.sqs"]
tx_AssasinArray = ["Missions\AssasinA.sqs","Missions\AssasinB.sqs","Missions\AssasinC.sqs"]
tx_RecceArray = ["Missions\RecceA.sqs","Missions\RecceB.sqs","Missions\RecceC.sqs"]
;;;Master Array
tx_Minimissions = [tx_AmbushArray,tx_AssasinArray,tx_RecceArray]
When required (via booleans and a monitoring script not shown) the following chain of scripts is run in this order
SERVER_SELECT.sqs(Server side script which randomly picks a master element position and a sub element position of the master element
?!(local server):exit
#START
tx_selectmission = false
#TYPE_SELECT
;; selects the master array element
tx_AA = count tx_minimissions
?(tx_AA < 1): goto "END"
tx_A= random tx_AA
tx_A = (tx_A - tx_A mod 1)
?(tx_A == tx_AA): tx_A = tx_A - 1
#MISSION_SELECT
;; selects a subarray element of the masterArray element
tx_BB = 0
{tx_BB= (Count _x)} ForEach tx_Minimissions select tx_A
tx_B= random tx_BB
tx_B = (tx_B - tx_B mod 1)
?(tx_B == tx_BB): tx_B = tx_B - 1
tx_sendmission = true
#PV
{PublicVariable _x;}foreach["tx_A","tx_B","tx_sendmission"]
exit
#END
hint "Debug NO MORE MISSIONS AVAIL"
exit
Once the above script has run it's course, the next script is then started up by a script monitoring the booleans (not shown)ALL_SET.sqsHaving received the public variables, this "local to all" script then selects the actual element that the random script decided on and then processes it eg [] exec _mission
#START
tx_sendmission = false
#SET_MISSION
_minimissions = tx_minimissions
;;following is array created from masterArray element
_type = []
_type = _type + (_minimissions select tx_A)
;;following creates variable for the actual sting element in the sub array
_mission = _type select tx_B
_type = _type - [_mission]
_count = count _type
_minimissions set [tx_A, _type]
? (_count < 1): hint "Debug: Sub Array Empty"
;;The following line needs to remove the element from the masterarray if its subarrays are empty. (This is where my problem lies
as you can see i have tried many possibilities only a few shown here)
;;? (_count < 1):_Minimissions = _Minimissions - (_minimissions select tx_A)
;;? (_count < 1):_Minimissions = _Minimissions - [_minimissions select tx_A]
;;? (_count < 1):_Minimissions = _Minimissions - _type
? (_count < 1):_Minimissions = _Minimissions - [_type]
tx_minimissions = _minimissions
[] exec _mission
exit
#END
hint "NO MORE MISSIONS"
exit
once the _Mission that this script starts has run its course, it then starts up the
SERVER_SELECT.sqs and the loop continues
The problem is, when the subarray is empty and _count <1, i cannot remove the relevant array element from the _minimissions (tx_minimissions) array
the green coloured line is run, so the script does see the subarray as empty
so when the loop restarts at the server_select.sqs, the script still see's in this example 3 elements in the master array and thus is able to select a sub array which is empty
this then causes the loop system to fail
when running a debug, ,
_type or
_minimission select tx_A returns the contents of the subarray
not the actual masterarray element. eg "tx_RecceArray"
In advance........Many thanks for any help offered