Luduvo Contents
Theme
On this page

World

iterates the entities of the running place and registers the systems that run over them every tick

Methods

4 members Access: shared

DumpAttributes(entity: Instance?) -> ()

print attribute usage to the output

Parameters
NameTypeDescription
entityInstance?Entity instance to inspect.
returns()—
Each(component: string) -> () -> Instance?

iterate the entities that hold a component

Parameters
NameTypeDescription
componentstringComponent type to iterate over active entities.
returns() -> Instance?—
Query(...string) -> Query

build a cached multi-component query

Parameters and example
NameTypeDescription
...stringanyComponent names required by the query filter.
returnsQuery—
local query = game.World.Query("Tool")
local count = query:Refresh()
print("Matched tools count:", count)

for i = 1, query.count do
	local entity = query.Entity[i]
	print(string.format("Slot %d entity: %s", i, tostring(entity)))
end
System(name: string, q: Query, fn: (Query) -> (), phase: string?) -> ()

register a per-tick system over a query

Parameters
NameTypeDescription
namestringUnique system identifier reported in profiler stage metrics.
qQueryQuery selecting the entities and component arrays to iterate.
fn(Query) -> ()Callback invoked each tick with the query instance.
phasestring?One of "Default" or "Physics"; nil selects "Default".
returns()—

Running ECS Simulation Systems

Lifecycle: Server

A query paired with a system is the standard way to run per-tick logic over a set of entities.

Luau
local pickups = game.World.Query("Tool", "Position")game.World.System("pickup_simulation", pickups, function(q)	for i = 1, q.count do		local entity = q.Entity[i]		local position = q.Position[i]		local count, hits = game.Physics.OverlapBox(position, Vector3.new(1, 1, 1))		for h = 1, count do			-- Handle pickup collision interaction		end	endend)