Motion_Blurz Posted July 24, 2022 Share Posted July 24, 2022 Is there any nifty way of enumerating maps for a specific map object and then having it generate either a trigger zone or IP? Say I want to find every radio_tower the map has in it. How can I do that in a more time efficient means than visually scanning the map manually? Thanks in advance. Link to comment Share on other sites More sharing options...
Grimes Posted July 25, 2022 Share Posted July 25, 2022 You scan the map via script then save that information for later use. https://wiki.hoggitworld.com/view/DCS_func_searchObjects If scanning the whole map I like to save the object type name and the coordinates since the object ID cannot be relied on. Depending on the object searched for your results may or may not be all that practical. I ripped this out of a rather complicated mission script where it had a number of different input values. Anyway I used this primarily to just find and more easily associate an object with the object typename. Just place an F10 mark panel on the map, edit the box to say "searchObj" and it will scan a 500m radius around that point. For everything it detects it draws a mark panel over it with the object typename as the text for it. Change the 500 to a larger value if you want. Just know it will take a while because most of the maps have several million objects on them and checking even a 10km radius can take several minutes. Not to mention the f10 map really doesn't like rendering tens of thousands of mark panels. local mId = 0 local eHandler = {} local function searchAreaForObjs(vars) if vars.coord then local newPoint = vars.coord newPoint.y = land.getHeight({x = vars.coord.x, y = vars.coord.z}) local volS = { id = world.VolumeType.SPHERE, params = {point = newPoint } } volS.params.radius = vars.radius or 500 local searchInclude = {} if vars.searchFor and vars.searchFor[1] then for i = 1, #vars.searchFor do searchInclude[vars.searchFor[i]] = true end else searchInclude = vars.searchFor end local objs = {} local function ifFound(obj) if searchInclude and searchInclude[obj:getTypeName()] or not searchInclude then table.insert(objs, obj) if vars.debug then mId = mId + 1 trigger.action.markToAll(mId, obj:getTypeName(), obj:getPoint()) end end end world.searchObjects(Object.Category.SCENERY, volS, ifFound) -- search area for objects return objs end end function eHandler:onEvent(event) if event.id == 26 then if event.text then local calVals = {coord = event.pos, debug = true} if string.find(event.text, 'radius') then calVals.radius = tonumber(string.format(event.text, '%d+')) end if string.find(event.text, 'searchObj') then searchAreaForObjs(calVals) end end end end world.addEventHandler(eHandler) 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Recommended Posts