From 47367c3e610f2910edf1046cd6778c543ad036e9 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Fri, 8 May 2015 14:08:53 +0200 Subject: [PATCH] new command to list entities of a certain type enumentities Returns a list of the numbers of all entities of that type. If no such entities exist or the entity type could not be recognised, the list is empty. DOCREF enumentities --- config/scripts.cfg | 1 + source/src/world.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/config/scripts.cfg b/config/scripts.cfg index 144a3e3a..6e1262b2 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -95,6 +95,7 @@ looplist [ newent ents clearents ents closestenttype ents + enumentities ents weapon weapons burstshots weapons team teamnames diff --git a/source/src/world.cpp b/source/src/world.cpp index 98b6735c..602c221c 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -418,6 +418,16 @@ void editentity(char **args, int numargs) // index x y z a1 a2 a3 a4 ... } COMMAND(editentity, "v"); +void enumentities(char *type) +{ + vector res; + int t = getlistindex(type, entnames, false, -1); + loopv(ents) if(ents[i].type == t) cvecprintf(res, "%d ", i); + if(!res.length()) res.add('\0'); + else res.last() = '\0'; + result(res.getbuf()); +} +COMMAND(enumentities, "s"); void scalecomp(uchar &c, int intens) {