function QueuedTriggerRemoveByIndex takes integer trigIndex returns boolean
local integer index
// If the to-be-removed index is out of range, fail.
if (trigIndex >= bj_queuedExecTotal) then
return false
endif
// Shift all queue entries down to fill in the gap.
set bj_queuedExecTotal = bj_queuedExecTotal - 1
set index = trigIndex
loop
exitwhen index >= bj_queuedExecTotal
set bj_queuedExecTriggers[index] = bj_queuedExecTriggers[index + 1]
set bj_queuedExecUseConds[index] = bj_queuedExecUseConds[index + 1]
set index = index + 1
endloop
return true
endfunction