Forum

> > CS2D > Scripts > entitylist() : specific entity
Forums overviewCS2D overview Scripts overviewLog in to reply

English entitylist() : specific entity

1 reply
To the start Previous 1 Next To the start

old entitylist() : specific entity

LoaderFRA
User Off Offline

Quote
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 has written
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 has written
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.

old Re: entitylist() : specific entity

DC
Admin Off Offline

Quote
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.
edited 1×, last 27.11.22 06:12:14 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview