core.engine.get_entity_by_net_id

Shared

Retrieves a registered entity instance by its network identifier


Syntax

local result = core.engine.get_entity_by_net_id(net_id)

Parameters

TypeNameDescription
intnet_idNetwork identifier of the target entity
Must be a positive integer assigned by the network manager

Returns

TypeNameDescription
entity | boolresultEntity instance matching the given net_id, or false otherwise

Examples

Retrieves an entity by its net-id
local net_id = 1001
local entity = core.engine.get_entity_by_net_id(net_id)

if entity then
    core.engine.print("info", "Retrieved entity:", entity, string.format("(%s)", entity:get_type()))
else
    core.engine.print("warn", "No entity found for net_id:", net_id)
end

On this page