Jump to content

Recommended Posts

Posted (edited)

i need read a dead static units (for random smoke), but i can read only buildings, not static ded units like tanks, trucks.... with dead option. Can you help me plz? 

this is my lua

local function listAllObjects()
    local objects = {}

    -- Iterate through all coalitions (RED, BLUE, NEUTRAL)
    for _, coalitionId in ipairs({coalition.side.RED, coalition.side.BLUE, coalition.side.NEUTRAL}) do
        -- Get all groups in the coalition
        local groups = coalition.getGroups(coalitionId)
        if groups then
            for _, group in ipairs(groups) do
                local units = group:getUnits() -- Get all units in the group
                if units then
                    for _, unit in ipairs(units) do
                        if unit and unit:getName() then
                            table.insert(objects, "Unit: " .. unit:getName()) -- Add unit name to the list
                        end
                    end
                end
            end
        end

        -- Get all static objects in the coalition
        local staticObjects = coalition.getStaticObjects(coalitionId)
        if staticObjects then
            for _, static in ipairs(staticObjects) do
                if static and static:getName() then
                    table.insert(objects, "Static: " .. static:getName()) -- Add static object name to the list
                end
            end
        end
    end

    -- Use world.searchObjects to include static objects marked as "DEAD"
    world.searchObjects(Object.Category.STATIC, { -- Search all static objects
        id = world.VolumeType.SPHERE, -- Search within a sphere
        params = {
            point = {x = 0, y = 0, z = 0}, -- Center of the search area (world coordinates)
            radius = 1000000 -- Large radius to cover the entire map
        }
    }, function(static)
        if static and static:getName() then
            table.insert(objects, "Static (World): " .. static:getName()) -- Add static object name to the list
        end
        return true -- Continue searching
    end)

    -- Create text to display
    local text = "Object Names:\n"
    for _, name in ipairs(objects) do
        text = text .. name .. "\n"
    end

    -- Display the text in-game for 10 seconds
    trigger.action.outText(text, 10)
end

-- Execute the function
listAllObjects()


 

 

 

null

image.png

Edited by Dovivan
  • Dovivan changed the title to i can identify dead static buildings, but not static dead units.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...