On Sat, Jan 08, 2011 at 02:51:04AM -0800, beo wulf wrote:
> I want a function to do the following:
> 
> If there is a client that matches  'name="Grendel"' then I want that
> client to gain focus.
> If there is no such client that matches 'name="Grendel"' then I want
> "start-monster" to be executed.
> 
> Now, I know how to send focus to a client, and I know how to spawn
> monsters. Question is -- how do I figure out whether there is a client
> that matches 'name="Grendel"'?
> 
> Thanks!
> 
> -- 
> To unsubscribe, send mail to [email protected].
> 

client.get() returns a table of all managed clients. You can use pairs()
to iterate over that and do .name:match("whatever") for each client.
Something like this should do:

for _, c in pairs(client.get()) do
    if c.name:match("whatever") then
        whatever()
        break
    end
end

that loop would abort after the first client it found. Remove the
'break' to have it iterate over all clients.

-- 
    $l="\n";$p=q-sub r{rand}sub c{((shift)**2+(shift)**2)<1}while(
    $i++<=$s){$t++if c r,r}die("Gregor Best, 0xDB9F9A7C, ".($t/$s*
    4).$l)-;$s+=ord$$|$_ for split //,$p;srand($s|$$);eval$p;die$@

Attachment: pgpMRI5Y5D3lq.pgp
Description: PGP signature

Reply via email to