Jump to content

Get all zones


Wrench

Recommended Posts

No direct function but anything in the mission file is accessible to the scripting engine as a table env.mission. They are indexed numerically. So you can open a .miz file and then open the mission file in notepad++ to note the formatting. In this case it is:

 

env.mission.triggers.zones = {listOfZones}

 

They are in this format.

           [2] = 
           {
               ["y"] = -1606.310285714,
               ["radius"] = 22.86,
               ["zoneId"] = 58,
               ["x"] = 107906.32142857,
               ["color"] = 
               {
                   [1] = 1,
                   [2] = 1,
                   [3] = 1,
                   [4] = 0.15,
               }, -- end of ["color"]
               ["hidden"] = false,
               ["name"] = "Naval Staff",
           }, -- end of [2]

 

For instance this his how mist creates a DB of the zones

	if env.mission.triggers and env.mission.triggers.zones then
		for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
			if type(zone_data) == 'table' then
				local zone = mist.utils.deepCopy(zone_data)
				zone.point = {}	-- point is used by SSE
				zone.point.x = zone_data.x
				zone.point.y = 0
				zone.point.z = zone_data.y

				mist.DBs.zonesByName[zone_data.name] = zone
				mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone)	--[[deepcopy so that the zone in zones_by_name and the zone in
																							zones_by_num se are different objects.. don't want them linked.]]
			end
		end
	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

Link to comment
Share on other sites

Hi

 

Hey all, is there a way to get get all the zones defined in the ME?

something like getZones()?

 

Thanks for asking.

 

I was about to ask it :smilewink:

 

And thanks Grimes for the answer.

Always there and helpfull :thumbup:

 

 

 

Thans so much


Edited by CougarFFW04
Link to comment
Share on other sites

Just post the questions on the forums because it allows other people to learn something or find it if they have the same question.

  • Like 1

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

Link to comment
Share on other sites

Its in the DB tables for mist.

 

mist.DBs.zonesByName

mist.DBs.zonesByNum

 

So iterate those however you want to get the zones.

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

Link to comment
Share on other sites

https://github.com/mrSkortch/MissionScriptingTools/blob/master/Example%20DBs/mist_DBs_zonesByName.lua

 

Mist saves a table of all of the zones in the mission. It is basically what would be returned via getAllZones() type of function. The following would create red smoke at 0 ASL at the center of each zone.

 

 

for tName, tData in pairs(mist.DBs.zonesByName) do
trigger.action.smoke(tData.point, 1) 
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

Link to comment
Share on other sites

  • Recently Browsing   0 members

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