See also: pos()
& LSEARCH()
+& NLSEARCH()
& SEARCH()
+& NSEARCH()
& LSEARCHR()
& CHILDREN()
+& NCHILDREN()
lsearch(<player>[, <class>[, <restriction>]])
+ nlsearch(<player>[, <class>[, <restriction>]])
lsearchr(<player>[, <class>[, <restriction>]])
children(<object>)
+ nchildren(<object>)
This function is similar to the @search command, except it returns
just a list of dbref numbers. It is computationally expensive, and
children() is exactly the same as lsearch(<me|all>,parent,<object>),
using "all" for See_All/Search_All players and "me" for others.
+ nlsearch(...) and nchildren(...) return the count of results that
+ would be returned by lsearch() or children() with the same args.
+
See 'help lsearch2' for more details.
& LSEARCH2
& SEARCH2
{"NAMEGRABALL", fun_namegraball, 2, 3, FN_REG},
{"NAND", fun_nand, 1, INT_MAX, FN_REG},
{"NATTR", fun_nattr, 1, 1, FN_REG},
+ {"NCHILDREN", fun_lsearch, 1, 1, FN_REG},
{"NCON", fun_dbwalker, 1, 1, FN_REG},
{"NEXITS", fun_dbwalker, 1, 1, FN_REG},
{"NPLAYERS", fun_dbwalker, 1, 1, FN_REG},
{"NEARBY", fun_nearby, 2, 2, FN_REG},
{"NEQ", fun_neq, 2, 2, FN_REG},
{"NEXT", fun_next, 1, 1, FN_REG},
+ {"NLSEARCH", fun_lsearch, 1, INT_MAX, FN_REG},
{"NOR", fun_nor, 1, INT_MAX, FN_REG},
{"NOT", fun_not, 1, 1, FN_REG},
#ifdef CHAT_SYSTEM
{"NSCEMIT", fun_cemit, 2, 3, FN_REG},
#endif /* CHAT_SYSTEM */
+ {"NSEARCH", fun_lsearch, 1, INT_MAX, FN_REG},
{"NSEMIT", fun_emit, 1, -1, FN_REG},
{"NSLEMIT", fun_lemit, 1, -1, FN_REG},
{"NSOEMIT", fun_oemit, 2, -2, FN_REG},
FUNCTION(fun_lsearch)
{
int nresults;
+ int return_count = 0;
dbref *results = NULL;
int rev = !strcmp(called_as, "LSEARCHR");
return;
}
- if (!strcmp(called_as, "CHILDREN")) {
+ if (called_as[0] == 'N') {
+ /* Return the count, not the values */
+ return_count = 1;
+ }
+
+ if (!strcmp(called_as, "CHILDREN") || !strcmp(called_as, "NCHILDREN")) {
const char *myargs[2];
myargs[0] = "PARENT";
myargs[1] = args[0];
nresults = raw_search(executor, NULL, 2, myargs, &results, pe_info);
- } else
+ } else {
nresults =
raw_search(executor, args[0], nargs - 1, (const char **) (args + 1),
&results, pe_info);
+ }
if (nresults < 0) {
safe_str("#-1", buff, bp);
+ } else if (return_count) {
+ safe_integer(nresults, buff, bp);
} else if (nresults == 0) {
notify(executor, T("Nothing found."));
} else {