Commanding the soldiers does not take game it. Everything else your hero does takes game time, so command your soldiers first:
loop:
#command soldiers
#command hero
you already have the command hero part in the loop
If you are not sure how to command each soldier in soldiers go back to earlier levels for example, or see
the discussion on Mountain Mercenaries for how to give orders to each soldier: