Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

event.target and event.initiator are objects, specifically unit objects, while the mist.DBs.humansByName and ctld.transportPilotNames are tables. So that code you wrote would never return true.

 

So lets look at my example:

if event.target and mist.DBs.humansByName[unit.getName(event.target)] then

 

The mist.DBs.humansByName table is indexed by unit names. What I am doing is I am running the object function Unit.getName() on the unit object to return its name as a string. Then checking if there is an entry for it in the humansByName table.

 

 

A more correct version of what that might looks like would be something like this:

 

local uName = Unit.getName(event.target)
if ctld.transportPilotNames[uName] and mist.DBs.humansByName[uName] then
-- whatever
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

  • 3 weeks later...
Stupid question, how do I give the units I randomly spawn a random patrol route?

 

You can use mist.groupToRandomPoint function from MIST to actually create a route to a a given point. If you add a radius when calling the function then the destination would be a random point in that particular zone (basically a circle with having the center the point you have given initially).

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

  • 1 month later...

When spawning vehicle convoys on the NTTR map, they start to head to their original WP but some vehicles will veer off in another direction. Sometimes, the entire convoy will simply stop long before they reach their WP. I'm using t5he same script on the Caucasus map and while the vehicles may still veer off a little, they eventually reach their WP.

 

Pxb1oyH.gif

 

do
local gp = mist.respawnInZone('__RESPAWN__W_GROUP_1', {'SPAWN_1', 'SPAWN_2', 'SPAWN_3', 'SPAWN_4', 'SPAWN_5', 'SPAWN_6'}, false)
local newRoute = mist.getGroupRoute('__RESPAWN__W_GROUP_1')
mist.goRoute(gp.name, newRoute)
end

 

 

Same results happen with teleport/cloneInZone as well.

 

Is this a bug or am I using the wrong setup here? I have nothing else in the mission interacting with the convoy so they should head straight to WP.


Edited by maverickturner
added example.gif
Link to comment
Share on other sites

There is a known bug of some odd waypoint pathing on NTTR. Even though its a straight line and the AI should drive it like that the actual path created is usually everything bug straight. There should be a F10 map option up there to see the path created. Then thats compounded by the AI generally "giving up" if they don't reach destination within a set timeframe of their expected arrival at the WP. Will test it out though.

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

Hey Grimes, found a bug in mist.

 

Function mist.getAvgGroupPos contains a loop with an erroneous # reference.

 

for i = 1, #groupName:getSize() do
table.insert(units, groupName.getUnit(i):getName())
end

 

Should be:

for i = 1, groupName:getSize() do
table.insert(units, groupName.getUnit(i):getName())
end

 

or

 


for i = 1, #groupName:getUnits() do
table.insert(units, groupName.getUnit(i):getName())
end

 

Isnt it? However changing it to either one throws a "parameter #self missed" error though by the line

 

table.insert(units, groupName.getUnit(i):getName())

 

Which I suppose should be:

 

table.insert(units, groupName:getUnit(i):getName())


Edited by chrisofsweden

GPU: PALIT NVIDIA RTX 3080 10GB | CPU: Intel Core i7-9700K 4,9GHz | RAM: 64GB DDR4 3000MHz
VR: HP Reverb G2 | HOTAS: TM Warthog Throttle and Stick
OS: Windows 10 22H2

Link to comment
Share on other sites

  • 2 weeks later...

On my MiST wishlist:

 

When calling mist.respawnGroup, if the group to be respawned is set to late activation in the mission editor, it would be good if mist.respawnGroup removed the late activation attribute from the new cloned group.

 

It causes several issues that attribute ["lateActivation"] seems to remain on a respawned (cloned) group.

GPU: PALIT NVIDIA RTX 3080 10GB | CPU: Intel Core i7-9700K 4,9GHz | RAM: 64GB DDR4 3000MHz
VR: HP Reverb G2 | HOTAS: TM Warthog Throttle and Stick
OS: Windows 10 22H2

Link to comment
Share on other sites

Noob question but is it possible to change the time of the mission in the mission with scripts?
Nope!

Shagrat

 

- Flying Sims since 1984 -:pilotfly:

Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B  | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore)

Link to comment
Share on other sites

Hi, how can I spawn something in radius at player position?

Or at player position?

 

I can spawn stuff at zones, but if I want to spawn stuff at a players position or a radius around a player, how do I do that with mist?

Link to comment
Share on other sites

mist.teleportToPoint

 

So something like this.

 

local vars = {
groupName = 'whatever'
point = Unit.getByName('player'):getPoint()
action = 'respawn'
radius = 1000
}

 

You can also do it directly via mist.dynAdd() if you have a table of the objects you want and wanna generate the coordinates yourself.

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

mist.teleportToPoint

 

So something like this.

 

local vars = {
groupName = 'whatever'
point = Unit.getByName('player'):getPoint()
action = 'respawn'
radius = 1000
}

 

You can also do it directly via mist.dynAdd() if you have a table of the objects you want and wanna generate the coordinates yourself.

 

Thanks, and how do I use it with this code?

local groupName = 'testGroup'
local point = 'zone'
mist.respawnInZone(groupName, point, true)

 

My player group and name is Player #009, where I want the Group 1 to be spawned at.


Edited by Kiptanoi
Link to comment
Share on other sites

mist.makeUnitTable

 

Greetings,

 

(I guess the following is roughly 50% general LUA and 50% MIST issue...)

I wish to define a table which will contain specific unit names (specific MBT's and IFV's for that matter)

From my extremely (!!) basic understanding in both LUA and MIST, I understand that mist.makeUnitTable should be the way to go.

Could anyone point me to an example of how the code should look like?

I figure I need the table name to be included later on in other functions (units in zones etc) but how do I practically define the table name and its content within DCS?

 

Thanks!

Assaf.

Link to comment
Share on other sites

  • 2 weeks later...

When using mist.respawngroup, if respawning a tanker callsign Arco placed in the ME, the unit respawns as Texaco. Does this function not copy callsign?

GPU: PALIT NVIDIA RTX 3080 10GB | CPU: Intel Core i7-9700K 4,9GHz | RAM: 64GB DDR4 3000MHz
VR: HP Reverb G2 | HOTAS: TM Warthog Throttle and Stick
OS: Windows 10 22H2

Link to comment
Share on other sites

Messages to Combined Arms?

 

Hi,

Trying to set some messages to be delivered to CA players.

When in the msgFor line I set

 

{CA = {'blue'}}

 

The CA player receives a ton of messages. See screenshot

https://imgur.com/a/nma0KtL

 

(The screenshot is when using mist.msgLL but the issue is the same with simple MIST messages as well)

 

Is this normal?

Have near-zero LUA understanding so I don't really know what am I looking for:huh:

 

Thanks!

Link to comment
Share on other sites

solved it...

 

Mind explaining what/how you solved it? Might help someone in future doing the same thing.

B. "Swany" Swanberg

Gigabyte Designare, Intel i9 9900KF (3.6, OC'd to 5.0)

32GB Patriot Viper Steel (black, non-RGB)

OS installed on a Samsung Evo 970 1TB SSD

DCS installed on a Samsun Evo 860 1TB SSD

EVGA 2080Ti 11GB

EVGA Supernova 720p 750w PS

3 Dell S2716DG monitors in Surround mode (7680x1440)

Oculus Rift S VR

Thrustmaster Warthog Throttle and Stick

Thrusmaster Rudder Pedals

assorted button boxes/Arduino boards

All drivers always kept up to date (30 days old, max)

Link to comment
Share on other sites

Just me being tired and not realizing the zone radius in mist is in meters, I was completely focused on feets and nm. If this help anyone I will be glad. So again to be sure, Zone radius in mist is in meters! :thumbup:

Link to comment
Share on other sites

Is there a way to add groups spawned in from moose to the mist database.

 

 

Mist checks for any object spawned into the game via the "birth" events and adds it to the DBs. It may take a second or two to occur though. DBs that have "ME" in their name won't be updated as those only list stuff from the mission editor.

 

 

Is it in some way to get "displaced moving zones"?

 

 

Just a fair amount of trig and liberal usage of sine and cosine. Depending on what you are trying to do, it might be easier to do it a different way.

 

 

Your way:

 

Get heading/range from unit to each zone.

 

When checking for objects, get the units heading and for each zone add that to the offset heading, then sine/cosine for the X, Z (or other way around) + offset distance. Now you have the new center of the zone.

Give the old Pythagorean a go to see if objects are in the zone.

 

 

 

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

-- unit in zone

end

 

 

The other way to do it, which sorta looks like you might be wanting to do it that way, is to get the relative "O clock" of objects from a unit. You just do a singular large zone to see which objects are in it. Get the heading of your unit and the relative bearing to the target, and see which 30 degree range that bearing falls into.

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

having trouble trying to respawn when a group is dead - I am very very very new to this

 

mist.flagFunc.group_dead {

units='RedAir1,flag=100, toggle=true,}

 

I get [strin "mist.flagFunc.group_dead {…"]:2:unfinished string near'<eof>

 

 

I checked to make sure RedAir1 is alive (its set to uncontrolled and present)

 

 

I know this will be something silly I am missing but ….. Any help would be appreciated

Link to comment
Share on other sites

When checking for objects, get the units heading and for each zone add that to the offset heading, then sine/cosine for the X, Z (or other way around) + offset distance. Now you have the new center of the zone.

Give the old Pythagorean a go to see if objects are in the zone.

 

 

 

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

-- unit in zone

end

 

 

The other way to do it, which sorta looks like you might be wanting to do it that way, is to get the relative "O clock" of objects from a unit. You just do a singular large zone to see which objects are in it. Get the heading of your unit and the relative bearing to the target, and see which 30 degree range that bearing falls into.

 

Thank you Grimes, so it is possible :thumbup:

Link to comment
Share on other sites

is there a way to get a jets current payload. I seen how Grimes used to get his functions in mist but it does not work if your dynamically spawning units with different group IDs.

 

Yes I believe there is, check out "mist.getGroupData(groupName)". I believe this will also give every units loadout.

 

Edit: Something like this:

local myGroupData = mist.getGroupData(myGroupName) -- gets all data for the referenced group name
trigger.action.outText(mist.utils.tableShow(myGroupData), 25)  -- will show data on screen
env.info(mist.utils.tableShow(myGroupData))  -- will show data in log


Edited by HiJack
Link to comment
Share on other sites

  • Recently Browsing   0 members

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