lul
This commit is contained in:
34
Assets/lua/entity_scanner.lua
Normal file
34
Assets/lua/entity_scanner.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- ============================================================================
|
||||
-- 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
|
||||
Reference in New Issue
Block a user