Skip to main content

View

Provides random access to the results of a query.

Calling the View is equivalent to iterating a query.

for id, player, health, poison in world:query(Player, Health, Poison):view() do
	-- Do something
end

Functions

get

View:get(
entityIdnumber--

the entity ID

) → ...ComponentInstance

Retrieve the query results to corresponding entity

contains

View:contains(
entityIdnumber--

the entity ID

) → boolean

Equivalent to world:contains()

Show raw api
{
    "functions": [
        {
            "name": "get",
            "desc": "Retrieve the query results to corresponding `entity`\n\t\t",
            "params": [
                {
                    "name": "entityId",
                    "desc": "the entity ID",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "...ComponentInstance"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 939,
                "path": "lib/World.luau"
            }
        },
        {
            "name": "contains",
            "desc": "Equivalent to `world:contains()`\n\t\t",
            "params": [
                {
                    "name": "entityId",
                    "desc": "the entity ID",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 956,
                "path": "lib/World.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "View",
    "desc": "Provides random access to the results of a query.\n\nCalling the View is equivalent to iterating a query.\n\n```lua\nfor id, player, health, poison in world:query(Player, Health, Poison):view() do\n\t-- Do something\nend\n```\n\t",
    "source": {
        "line": 901,
        "path": "lib/World.luau"
    }
}