eekz Posted August 21, 2014 Share Posted August 21, 2014 Could you please give and example of using this function function array of Airbase world.searchObjects([array of enum Object.Category] or [Object.Category] objectCategory, Volume volume, ObjectSearchHandler handler, any data) if we have volume: VolumeSphere = { id = world.VolumeType.SPHERE, params = { point = Vec3, radius = Distance } } and we need to get STATIC objects from this volume. Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
Grimes Posted August 21, 2014 Share Posted August 21, 2014 local sphere = trigger.misc.getZone('town') local volS = { id = world.VolumeType.SPHERE, params = { point = sphere.point, radius = sphere.radius } } local ifFound = function(foundItem, val) if foundItem:getTypeName() == val then env.info('Tech static object found') end return true end world.searchObjects(Object.Category.STATIC, volS, ifFound, 'TECH') world.searchObjects checks volS as defined by a trigger zone placed in the editor for a static object called "TECH" using the function 'ifFound'. 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...
eekz Posted August 21, 2014 Author Share Posted August 21, 2014 :worthy: Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
eekz Posted August 21, 2014 Author Share Posted August 21, 2014 (edited) With your help, I've done that thingy: local sphere = trigger.misc.getZone('kobuleti') local volS = { id = world.VolumeType.SPHERE, params = { point = sphere.point, radius = sphere.radius } } local ifFound = function(foundItem, val) val = foundItem:getTypeName() env.info(val .. 'Scenery object found') return true end world.searchObjects(Object.Category.SCENERY, volS, ifFound, val); :) Going to add userflag increase by 1 on every found object and make this check periodically, if userflag = 0 then all scenery objects in zone destroyed. Seems nice perspectives of making ground targets with not need to painfully putting every single static in ME. Edited August 21, 2014 by eekz Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
eekz Posted December 7, 2015 Author Share Posted December 7, 2015 UP Is it possible to search in trigger zone but not in volume? Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
JackDant Posted December 8, 2015 Share Posted December 8, 2015 UP Is it possible to search in trigger zone but not in volume? You can search in a sphere, and then use land.getHeight to filter out anything not on the ground. FYI, in 1.5 I've found searchObjects is a bit fragile when the callback has any sort of error. It doesn't report the error, and it breaks searchObjects until you restart the game entirely. So I've taken to use pcall like this this: local searchCallback = function (object, data) local status, err = pcall(function () self:storeBuilding(object, data) end) if err then env.error("Something went wrong searching " .. err) end return true end local vol = { id = world.VolumeType.BOX, params = { min = self:getMin(), max = self:getMax(), } } world.searchObjects(Object.Category.SCENERY, vol, searchCallback, store) Link to comment Share on other sites More sharing options...
eekz Posted December 8, 2015 Author Share Posted December 8, 2015 (edited) You can search in a sphere, and then use land.getHeight to filter out anything not on the ground. FYI, in 1.5 I've found searchObjects is a bit fragile when the callback has any sort of error. It doesn't report the error, and it breaks searchObjects until you restart the game entirely. So I've taken to use pcall like this this: Yep, I know, but I need a cylinder with unlimited heigh but not a sphere :) Currently it seems that it's impossible to create with current volume types. Probably it's possible to hack using found object coordinates projection to the ground and if projected point in the sphere then return true... Need to work on that :) Edited December 8, 2015 by eekz Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
JackDant Posted December 8, 2015 Share Posted December 8, 2015 Yep, I know, but I need a cylinder with unlimited heigh but not a sphere :) Then it might be easiest to use a box volume: local vol = { id = world.VolumeType.BOX, params = { min = {x=center.x-radius, z=center.y-radius, y=0}, max = {x=center.x+radius, z=center.y+radius, y=math.huge}, -- Or a high altitude if math.huge doesn't work } } And in the search callback you can calculate the 2D distance between the center and the object and filter on that. Link to comment Share on other sites More sharing options...
eekz Posted December 8, 2015 Author Share Posted December 8, 2015 Thanks for advice! Will look into it! Куплю B-17, можно B-24. B-29 не предлагать! Burning Skies =Burning Skies= @ Facebook Link to comment Share on other sites More sharing options...
Recommended Posts