Files
sampleproj/Assets/lua/entity_scanner.lua
Jan Racek 1fdb223f5d lul
2026-03-29 09:34:46 +02:00

35 lines
1.2 KiB
Lua

-- ============================================================================
-- entity_scanner.lua - Scans all entities on interact (Entity.ForEach test)
-- ============================================================================
-- Tests: Entity.ForEach, Entity.GetPosition, Entity.IsActive, Entity.GetCount,
-- Entity.FindByIndex, onInteract
function onInteract(self)
setStatus("Scanning all entities...")
Debug.Log("=== Entity Scan ===")
Debug.Log("Total entities: " .. Entity.GetCount())
local activeCount = 0
local inactiveCount = 0
Entity.ForEach(function(obj)
local pos = Entity.GetPosition(obj)
local active = Entity.IsActive(obj)
if active then
activeCount = activeCount + 1
else
inactiveCount = inactiveCount + 1
end
end)
Debug.Log("Active: " .. activeCount .. " Inactive: " .. inactiveCount)
setStatus("Scan: " .. activeCount .. " active, " .. inactiveCount .. " inactive")
-- Test FindByIndex
local first = Entity.FindByIndex(0)
if first then
local pos = Entity.GetPosition(first)
Debug.Log("Entity 0 at " .. pos.x .. "," .. pos.y .. "," .. pos.z)
end
end