MOO-Cows

moo-cows Topic: find?

Article #1060
Subject: find?
Author: Mark O'Neil
Posted: 3/9/2001 03:40:21 PM

Hello all!

@find .real_name => a list of objects with the real name property just fine.

;$player_db:find("mao") => the player whos name is "mao"

;$player_db:find(".real_name") => fails even though mao has a property
.real_name

here is a screen dump:

@find .real_name
The property .real_name is on   Wizard(#2)--generic player(#6)
mao(#165)--generic player(#6)

;$player_db:find("mao")
=> #165  (mao)

;$player_db:find(".real_name")
=> #-3  <$failed_match>


What am I missing?

Thanks,
-m


Responses:

Article #1061
Subject: Re: find?
Author: Seth I. Rich
Posted: 3/9/2001 05:01:01 PM

> @find .real_name => a list of objects with the real name property just fine.

Ok, this makes sense...

> ;$player_db:find("mao") => the player whos name is "mao"

Ok, this makes sense...

> ;$player_db:find(".real_name") => fails even though mao has a property
> .real_name

$player_db:find is a function which takes a name and returns a player's
object number.  You're asking for the player whose name is ".real_name"
and I am not surprised you don't have one.

Seth
--
-------------------------------------------------------------------
Seth I. Rich - seth@nospam         Rabbits on walls, no problem.


Article #1062
Subject: Re: find?
Author: Mark A. O'Neil
Posted: 3/9/2001 06:52:33 PM

--- You wrote:
$player_db:find is a function which takes a name and returns a player's
object number.  You're asking for the player whose name is ".real_name"
and I am not surprised you don't have one.
--- end of quote ---

ah, I was confusing the finds.

what I am looking for is something, similar to @find .real_name, that I can call like I was hoping to be able to do with $player_db:find(".real_name").

I want to get at a list of players (that have real_name set) so that I can compare the property real_name to a variable.

What would be the best way to approach this?

-m


Article #1063
Subject: Re: find?
Author: Chris Jones
Posted: 3/9/2001 07:13:18 PM

On Fri, 9 Mar 2001, Mark A. O'Neil wrote:
> I want to get at a list of players (that have real_name set) so that I
> can compare the property real_name to a variable.
>
> What would be the best way to approach this?

        $object_utils:descendants_with_property_suspended($player,
"real_name") is probably close to what you need.


Article #1064
Subject: Re: find?
Author: Matthew Kerwin
Posted: 3/9/2001 07:24:20 PM

>From: "Mark A. O'Neil" <Mark.A.O'Neil@nospam>

>I want to get at a list of players (that have real_name set) so that I can
>compare the property real_name to a variable.
>
>What would be the best way to approach this?

Maybe..

result = {};
for p in (players())
  if (p.real_name)
    result = {@result, p};
  endif
endfor
return result;

?
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Article #1065
Subject: Re: find?
Author: Matthew Kerwin
Posted: 3/9/2001 07:28:39 PM

Or, thinking more, if you make it result = {@result, {p, p.real_name}} it
saves having to go and get the .real_names again later.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Article #1066
Subject: Re: find?
Author: Mark A. O'Neil
Posted: 3/9/2001 09:40:40 PM

--- Chris Jones wrote:
$object_utils:descendants_with_property_suspended($player,
"real_name")
--- end of quote ---

Not familiar with that one - I will look into it.


--- Matthew Kerwin  wrote:
result = {};
for p in (players())
  if (p.real_name)
    result = {@result, p};
  endif
endfor
return result;
---

This was close to the route I was planning to go at if there was no 'given':

result = {};
for p in (players())
  if (p.real_name)
    if (p.real_name == usr_name)
      result = {p, usr_name};
      break;
  endif
endfor

"carry on with result...";

I can stop on finding a match as these names are guaranteed unique.

--- and:
Or, thinking more, if you make it result = {@result, {p, p.real_name}} it saves having to go and get the .real_names again later.
---

This would be perfect for collecting the list I was referring to. I mentioned list because that is what I thought 'find' would return and I figured I'd walk through that. Will hang on to the above though!

Many thanks everyone and a good weekend to you.

regards,
-m


Article #1067
Subject: Re: find?
Author: Cipriano Groenendal
Posted: 3/9/2001 11:14:23 PM

> --- Chris Jones wrote:
> $object_utils:descendants_with_property_suspended($player,
> "real_name")
> --- end of quote ---
> Not familiar with that one - I will look into it.
problem is this one can return non players aswell, and might miss players
that aren't children of $player(Odd, but it happens:)

> result = {};
> for p in (players())
>   if (p.real_name)
>     if (p.real_name == usr_name)
>       result = {p, usr_name};
>       break;
>   endif
> endfor

for p in (players())
  if (p.real_name == usr_name);
    return p;
  endif
  $command_utils:suspend_if_needed(0);
endfor
return #-1;

would probably work best if you're gonna use a seperate verb:)

> Or, thinking more, if you make it result = {@result, {p, p.real_name}} it
saves having to go and get the .real_names again later.
> This would be perfect for collecting the list I was referring to. I
mentioned list because that is what I thought 'find' would return and I
figured I'd walk through that. Will hang on to the above though!
You'd have to go use $list_utils:assoc() on this one afterwards tough:)


--
|| Cipriano Groenendal
|\______________________________       ___
| ______________________________| sig |___|
|/
|| MAIL: cipri@nospam
|| WWW:  http://www.cipri.com
|| MOO:  telnet://moo.NowMOO.nl:2001
|| ICQ:  #5820598  AIM:  Cieper
|| GF:   http://www.Cerala.com/
|\______________________________       ___
\_______________________________| eof |___|



MOO-Cows Home