function FindBookThingyByName(name, subname, booktype) local spellName = "smurf"; local subSpellName = "Rank 5"; local index = 1; -- thanks to Munelear for the nice loop condition :) while spellName do spellName, subSpellName = GetSpellName(index, booktype); if ( ( spellName ~= nil) and ( string.find(spellName, name) ~= nil) ) then if ( ( subname == nil ) or ( string.find(subSpellName, subname) ~= nil) ) ) then return index; end end index = index + 1; end return nil; end function FindSpellByName(name, subname) return FindBookThingyByName(name, subname, BOOKTYPE_SPELL); end function FindPetByName(name, subname) return FindBookThingy(name, subname, BOOKTYPE_PET); end function FindAbilityByName(name, subname) return FindBookThingyByName(name, subname, BOOKTYPE_ABILITY); end -- will return an index and then a book type. -- if the thingy is not found in any book it will return nil, nil function FindInAnyBookType(name, subname) local index = nil; for bookType, value in SPELLBOOK_PAGENUMBERS do index = FindBookThingyByName(name, subname, bookType); if (index ~= nil) then return index, bookType; end end return nil, nil; end AUTOKEY = 0; CUR_RECAST = 1; function SemiAutoFind() local time = GetTime(); if ( IN_ATTACK_MODE == 0 and ( time > AUTOKEY ) ) then local index = 0; local bookType = ""; if (CUR_RECAST == 1) then index, bookType = FindAbilityByName("Find Herbs", nil); if(index ~= nil) then CastSpell(index, bookType); AUTOKEY = time + 2; else AUTOKEY = time + 1; end CUR_RECAST = CUR_RECAST + 1; else index, bookType = FindAbilityByName("Find Minerals", nil); if(index ~= nil) then CastSpell(index, bookType); AUTOKEY = time + 150; else AUTOKEY = time + 150; end CUR_RECAST = 1; end end end