Forum

> > CS2D > Scripts > entitylist() : specific entity
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch entitylist() : specific entity

1 Antwort
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt entitylist() : specific entity

LoaderFRA
User Off Offline

Zitieren
Good aftertoon,

I looking for a script for to have list of all entity: trigger_use ONLY of the map because
if map("trigger_use")==1 then
-- error no exist

cs2d lua cmd map hat geschrieben
noweapons: are weapons allowed? 0/1
teleporters: are there any teleporters? 0/1
botnodes: number of bot nodes

but not trigger_use

cs2d lua cmd entitylist hat geschrieben
Categories : Entity
Parameters: [type] (optional)
I tested of myself but i have LUA ERROR: sys/lua/autorun/entitylist.lua:4: bad argument #1 to 'pairs' (table expected, got nil) or LUA ERROR: sys/lua/autorun/entitylist.lua:4: bad argument #1 to 'pairs' (table expected, got number) or near '<eof>' or other errors or no error and no works

Thanks at advance.

alt Re: entitylist() : specific entity

DC
Admin Off Offline

Zitieren
Sorry, that detail is missing in the documentation: cs2d lua cmd entitylist takes an optional type parameter but that must be the internal ID of an entity and NOT the name. I extended the documentation accordingly.

See https://www.cs2d.com/entities.php
What you'll want to use is the number in front of the name. It's 93 for cs2d entity trigger_use.

Also note that cs2d lua cmd entitylist returns a list of coordinates. Therefore you can't use it directly with if but you have to iterate the list in some way.

Sample which prints a list of all trigger_use entities on the map with their coordinates:
1
2
3
4
local list=entitylist(93)
for _,e in pairs(list) do
	print("trigger_use @ ("..e.x..","..e.y..") -"..entity(e.x,e.y,"typename"))
end

p.s.: cs2d lua cmd map does not accept entity names as parameters. Take a look at the documentation for a list of valid parameters.
1× editiert, zuletzt 27.11.22 18:12:14
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht