Class: World
Lua
C++
Edit

World:GetEntities

This method returns an array of all entities in the world, with optional filter parameters.

Syntax

Property Description
field the name of a field to check
operation the operation to perform. This can be set to "==", "~=", "<", ">", "<=", or ">="
value the value to compare the entity field value to. This can be any Lua value.

Returns

Returns an array-style table filled with all entities in the world that pass the specified filters.

Remarks

You can provide any number of arguments, in sets of three. Each three arguments will be used to test the values attached to an entity, using the specified operation.

For example, if you wanted to retrieve all entities in the world with a health value greater than zero, you would do this:

world:GetEntities("health", ">", 0)

If you wanted to retrieve all entities in the world with a health value greater than zero, that were carrying a weapon, you would do this:

world:GetEntities("health", ">", 0, "weapon", "~=", nil)

Although the name property is part of the Entity class and not technically a Lua field, it can still be used to retrieve entities by name.

Copyright © 2006-2025 Leadwerks Software.
All rights reserved.
Leadwerks 4 Documentation