entitylist() : specific entity
1 reply



27.11.22 04:16:10 pm
Good aftertoon,
I looking for a script for to have list of all entity: trigger_use ONLY of the map because
map has written:
but not trigger_use
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.
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
noweapons: are weapons allowed? 0/1
teleporters: are there any teleporters? 0/1
botnodes: number of bot nodes
teleporters: are there any teleporters? 0/1
botnodes: number of bot nodes
but not trigger_use

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.
Sorry, that detail is missing in the documentation:
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
trigger_use.
Also note that
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:
p.s.:
map does not accept entity names as parameters. Take a look at the documentation for a list of valid parameters.

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

Also note that

Sample which prints a list of all trigger_use entities on the map with their coordinates:
Code:
1
2
3
4
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
for _,e in pairs(list) do
print("trigger_use @ ("..e.x..","..e.y..") -"..entity(e.x,e.y,"typename"))
end
p.s.:

edited 1×, last 27.11.22 06:12:14 pm



