10 Apr, 2014, Valo wrote in the 1st comment:
Votes: 0
I'm trying to compile a list of players in a room by gender via the @sex attribute. I was wondering if anyone knew how to do this via the search() function. I can gather a full list of all players on the game, but I can't seem to figure out how to narrow the search to just one room. Thanks in advance.
10 Apr, 2014, plamzi wrote in the 2nd comment:
Votes: 0
Might help to be a bit more specific. Is your code in Perl, C++, etc?
11 Apr, 2014, Idealiad wrote in the 3rd comment:
Votes: 0
It's mushcode, AKA softcode, the Tiny family scripting language.

@Valo, do you want to sort all players by room and gender, or given a specific room dbref sort the players therein by gender?

Probably what you want to do is use the search class EPLAYER. This is a combination of type=Player and eval=<restriction> (see help search classes2). In the restriction the symbol ## gets replaced with the player's dbref, and if the restriction evaluates to true you get the player. So you can test if that player dbref is inside the room you're interested in. Once you have the list of players then sorting by @sex is a second step.

Something like (where you replace room-dbref with the one you want),

players = search(EPLAYER=strmatch(room(##), #<room-dbref>))
GENDERSORT = comp(get(%0/sex), get(%1/sex))
players-by-gender = sortby(v(GENDERSORT), players)


But all that said, you probably don't need search() to do this. If you have the dbref, you can get a lcon() of the contents, and sort that. It would be much more efficient since you're not searching the whole DB.
11 Apr, 2014, Valo wrote in the 4th comment:
Votes: 0
It's TinyMUX and I'm trying to get it in the location of a specific room, namely using [loc(%#)].
11 Apr, 2014, Idealiad wrote in the 5th comment:
Votes: 0
Sorry, edited after you posted. Maybe you just need lcon() then?
0.0/5