Jump to content

Recommended Posts

Posted

Greetings!

 

Is it possible to set a trigger to activate when a script spawned group is in a zone?

 

I know the name of the group, but since it's not editor placed, I can not select it when making the trigger.

Posted

If you are just wanting to set a flag you can use the mist.flagFunc.unitsInZones function. If you want to do other scripting its still a pretty simple check to write yourself. Just iterate each unit and get its position and do some math relative to the zone:

 

 

if ((unitPos.x - zone.x)^2 + (unitPos.z - zone.z)^2)^0.5 <= zone.radius then

-- unit is in the zone

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

If you know the name of the group you can get the unit names from that.

 

local units = Group.getByName('whatever'):getUnits()

local unitNameTable = {}

for i = 1, #units do

unitNameTable[#unitNameTable+1] = Unit.getName(units)

end

 

mist has a function that generates this for you.

 

local units = mist.makeUnitTable({'[g]whatever'})

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

Oh, cool!

 

I'm at work now so can't test it out. But would

 

mist.flagFunc.units_in_zones{units = mist.makeUnitTable({'[g]myGroup'}), zones = {'myZone'}, flag = 100, zone_type = 'sphere', toggle = true}

 

make flag 100 true when myGroup is in the zone myZone, and false when they are out?

Posted

I'm having trouble getting this to work with units that spawn into the mission. Is that expected or have I missed something?

Posted
I'm having trouble getting this to work with units that spawn into the mission. Is that expected or have I missed something?

 

Possibly missed something. This actually took me a few minutes to test and realize what was going on. Both of the following examples work. The difference is how the function acts as new units are added to the mission via scripting. The first example will update the unit list as needed, while the second example is fixed to whichever units were on blue when the function was first called. I added this to the documentation on the PDF, but never did for the wiki.

 

mist.flagFunc.units_in_zones({
units = {'[blue]'},
zones = {'zone'},
flag = '1'
})

 

mist.flagFunc.units_in_zones({
units = mist.makeUnitTable({'[blue]'}),
zones = {'zone'},
flag = '1'
})

 

There is a slight bug with my code in that it will throw an error if you used the second example and units were spawned in. I am correcting this at the moment. Will also update documentation as needed.

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

  • Recently Browsing   0 members

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