Jump to content

Recommended Posts

Posted

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:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

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:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
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

 

 

 

Posted

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:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • 5 years later...
Posted

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();

🍺 Snack Officer  🥨 
Intel I9-10850K (OC @ 5.0ghz) │ 64GB (4x16GB) DDR4 3200 │Gigabyte RTX 4090 Gaming OC 24gb
- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

  • Recently Browsing   0 members

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