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; AUTO_RECASTS = {}; AUTO_RECASTS[1] = { name = "Find Herbs", subname = nil, bookType = BOOKTYPE_ABILITY, delay = 2 }; AUTO_RECASTS[2] = { name = "Find Minerals", subname = nil, bookType = BOOKTYPE_ABILITY, delay = 150 }; function SemiAutoFind_HandleAutoRecast(recast) local index = 0; index = FindBookThingyByName(recast.name, recast.subname, recast.bookType); if(index ~= nil) then CastSpell(index, recast.bookType); end AUTOKEY = time + recast.delay; end function SemiAutoFind() local time = GetTime(); if ( IN_ATTACK_MODE == 0 and ( time > AUTOKEY ) ) then SemiAutoFind_HandleAutoRecast(AUTO_RECASTS[CUR_RECAST]); CUR_RECAST = CUR_RECAST + 1; if (CUR_RECAST > table.getn(AUTO_RECASTS) ) then CUR_RECAST = 1; end end end