;Separa mineral. Busca el mineral a separar en la mochila
; Ahora no se necesita ninguna posicion especfica

;Devuelve un valor %sepcontrol que puede ser SiSeparado/NoSeparado
;para poder saber si hemos acabado

if %separamos <> 1 
 exit

;Tiempo limite para encontrar un ore (2 segundos)
set %tiempomaximo #SCNT + 2

set %sepcontrol NoSeparado
SepStart:
; Sin buscar ores de tamao 1, aceleramos la busqueda
                        call keepalive
finditem %t_bigores

if %tiempomaximo <= #SCNT
   exit
if #findkind < 0
   exit

;Si no esta en la mochila principal no lo separamos
if #findbagid <> %mochilapr 
 {
  ignoreitem #FINDID
  goto SepStart
 }

;Ya tenemos un monton de mineral de dentro de la mochila

For %j 1 %oresdistintos
  {
   call ARRAY GET %j

   if #findcol = %3
     {
    ;Vemos si el codigo de ese mineral esta para separar
      if %1 IN %queseparar
         goto MineralASeparar       

      if %1 IN %evitar
         goto MineralAEvitar       
 
    ;Si no esta, lo ignoramos a partir de ahora
      ignoreitem #FINDID
      exit
     }
  }
;Si desconocemos el mineral tambien lo ignoramos
ignoreitem #FINDID
exit

MineralAEvitar:
 call keepalive
;Tiramos mineral malo cuando tenemos una cantidad considerable
 if #findstack > 9
   call drag #findid 337 241 ALL
 click 303 253 p
 ignoreitem #FINDID
exit

MineralASeparar:

 call keepalive
 call drag #findid 653 221 1
 set %sepcontrol SiSeparado
 ignoreitem #FINDID
SepEnd:
