Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Entity Queries #30

Open
charlesbthomas opened this issue Oct 23, 2024 · 1 comment
Open

Feature Request: Entity Queries #30

charlesbthomas opened this issue Oct 23, 2024 · 1 comment

Comments

@charlesbthomas
Copy link

charlesbthomas commented Oct 23, 2024

I find myself in need of the ability to query for and operate on more than one entity in systems sometimes. It would be nice tobe able to do something like:

local filter = tiny.requireAll("position", "otherComponent")
local entities = world.query(filter)

I understand that this library is considered feature complete, but this would be a handy feature!

@Fringale
Copy link

Fringale commented Jan 22, 2025

See 2nd request in #13 and https://bakpakin.github.io/tiny-ecs/doc/#System_functions: this can be done by using a vanilla system (a non-processing one, meaning it won't iterate over entities) and its entities field : )

Something like

local mySystem = tiny.system()
mySystem.filter = tiny.requireAll("position", "otherComponent")
function mySystem:update(dt)
    local entities =  self.entities
    -- operations on entities
end

or even without the update function

local mySystem = tiny.system()
mySystem.filter = tiny.requireAll("position", "otherComponent")
--
local filteredEntities =  mySystem.entities
-- operations on entities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants