Jump to content

Object.destroy


Recommended Posts

Weapons, Units, Static Objects, Scenery Objects, and even airbases all inherit the functions of the "object" class. Therefore the following will work just fine.

 

Unit.getByName('whatever'):destroy()

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

You have to use world.searchObjects() to define a search zone and to search for world objects. world.searchObjects() calls another function for each object it finds, from there you can do whatever you want with each object. This will destroy all objects with the name "house1' within a defined search volume.

do
local ifFound = function(foundItem, val) -- generic search for all scenery
if foundItem:getTypeName() == 'house1' then
foundItem:destroy()
end

end

world.searchObjects(Object.Category.SCENERY, volume, ifFound)

end

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

You have to use world.searchObjects() to define a search zone and to search for world objects. world.searchObjects() calls another function for each object it finds, from there you can do whatever you want with each object. This will destroy all objects with the name "house1' within a defined search volume.

do
local ifFound = function(foundItem, val) -- generic search for all scenery
if foundItem:getTypeName() == 'house1' then
foundItem:destroy()
end

end

   world.searchObjects(Object.Category.SCENERY, volume, ifFound)

end

 

I'm sorry but I do not understand how to pass volume

Volume is not specified good or I do not understand, as this variable step?

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Link to comment
Share on other sites

Sorry, I didn't include that bit as I simply paraphrased how the script works. Volume is just a variable you must define earlier. Check the wiki for the types of volumes you can do, but here his how you can create a spherical volume based on a trigger zone.

 

 local sphere = trigger.misc.getZone('zone')
 
 local newPoint = {x = sphere.point.x, y = land.getHeight({x = sphere.point.x, y = sphere.point.z}), z = sphere.point.z}
 local volS = {
 id = world.VolumeType.SPHERE,
	params = {
	 point = newPoint,
	 radius = sphere.radius
	}
	
 }

 

When you call the search you would use: world.searchObjects(Object.Category.SCENERY, volS, ifFound)

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 5 years later...

I know this is an old thread, but I was also trying to make a Static Object disappear, and this didn't work.

 

Weapons, Units, Static Objects, Scenery Objects, and even airbases all inherit the functions of the "object" class. Therefore the following will work just fine.

 

Unit.getByName('whatever'):destroy()

 

So, I wanted to post how I did get it to work...

 

 

StaticObject.getByName('Static F16 #001'):destroy();

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm

Gigabyte RTX 3080 Gaming OC 10gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 3x Acer 28" │ 1x 28" Touchscreen
- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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