Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

http://wiki.hoggit.us/view/RespawnGroup

mist.respawnGroup('groupName', 120)

 

Why does my group reborn at once?

 

The delay parameter in that function doesn't delay the respawn, it delays assignment of the group's original task. The group will respawn instantly, then, after the delay has passed, will begin to follow its original task again.

 

Edit: wow, this thread moves fast.

Black Shark, Harrier, and Hornet pilot

Many Words - Serial Fiction | Ka-50 Employment Guide | Ka-50 Avionics Cheat Sheet | Multiplayer Shooting Range Mission

Link to comment
Share on other sites

Is MIST working in 2.1 ATM?

 

Yes

 

Are respawnInZone and teleportInZone working for player groups? I can respawn the player using the basic respawnGroup, but when I try to use respawnInZone I get "Err: Can't execute trigger. Err: "mist.respawnInZone('PlayerGroup', 'SpawnZone', false)"

 

Substituting a non-player group works fine with no other changes to the syntax

 

 

Never tried it with player groups. If it is a client aircraft it won't work since client aircraft cannot be spawned, changed position, or modified in any way. The scripting function used, coalition.addGroup() by the mist functions is supposed to work if the skill is set to player and only in single player.

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

Yes

 

 

 

 

Never tried it with player groups. If it is a client aircraft it won't work since client aircraft cannot be spawned, changed position, or modified in any way. The scripting function used, coalition.addGroup() by the mist functions is supposed to work if the skill is set to player and only in single player.

 

Ah ok, was just curious as GCI CAP doesn't work and I thought it relied on that, sounds like something pertaining to GCI cap. Although Automan is dead too but that I don't think relies on MIST, I could be wrong I don't know too much about the coding side of things.

[sIGPIC][/sIGPIC]

Asus Z97-A/ i7-4790K/ Hyper 212 EVO/ 16GB RAM/ GTX1080 Strix OC/ Supernova 750/ X-55/ TiR

Link to comment
Share on other sites

Never tried it with player groups. If it is a client aircraft it won't work since client aircraft cannot be spawned, changed position, or modified in any way. The scripting function used, coalition.addGroup() by the mist functions is supposed to work if the skill is set to player and only in single player.

 

Yeah learned by trial and error that you can't respawn clients. Player groups work great for respawnGroup functions, but teleporting and respawnInZone seem to be a no-go.

Link to comment
Share on other sites

Hello.

 

 

i have a problem here with mist.removeFunction.

 

I have a function that display a message periodically every 4 seconds via...

 

local func = mist.scheduleFunction(aircraftposition, {"Mago 33"}, timer.getTime() , 4)

 

but then I use

 

mist.removeFunction(func) and it does not stop.

 

Any suggestion?

Link to comment
Share on other sites

Best guess is it is a locality issue. A good test would be to print out the value of func right after you call scheduleFunction and then again right before you call removeFunction.

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

I am not very good at this. Sorry, what do you mean for print out?

 

Edit> the question is, I want to practice "rejoinings" in a holding point. I set an AI aircraft doing orbits. So, when he is in certain positions he will say "I am in sector 1, 2, 3 or 4". The script works, but I dont know how to stop it.

 

I am using the formula.

 

function message()

 

bla bla bla

 

mist.schedulefunction(message,{},.....,4) so each 4 seconds the loop starts. But i dont know how to stop it. I am trying different formulas, but any help is welcomed.


Edited by ESAc_matador
Link to comment
Share on other sites

Finally. I got mist.ground.patrol working. A switched condition with a trigger zone around the last WP did the trick. I tried so many different combinations; At Mission Start with a Time More > 10; Once with the same Time More value, as a group triggered action, etc.

 

I chose that particular MIST function because I happened to see an example of it and it looked basic enough to start experimenting and learning how to use MIST. 3 hours later, it worked. However, (and there's always a 'however') I watched my 2-unit group run the route through 3 round trips and then it simply stopped at its starting point. The second test, I got tired of watching when it started its ninth round trip.

 

I've attached the tiny test mission if you're interested in seeing a successful use of mist.ground.patrol.

 

Question; can slmod and MIST run concurrently?

MIST_test.miz

Win 10 | i7 4770 @ 3.5GHz | 32GB DDR3 | 6 GB GTX1060

Link to comment
Share on other sites

I am not very good at this. Sorry, what do you mean for print out?

 

Using either mist.Logger or the scripting function env.info() to add entries to your DCS.log so you can get a better idea of what values are being passed. For example I added some logging directly to mist.removeFunction and the code I created to test this out real fast.

 

do
local function display()
	trigger.action.outText(Unit.getByName('u'):getPosition().p.x, 5, true)
end

fId = mist.scheduleFunction(display, {}, timer.getTime() +1, 1)
env.info(fId)
end

 

 

01459.011 INFO    SCRIPTING: Mist version 4.4.81 loaded.
01462.740 INFO    SCRIPTING: 1
01464.596 INFO    SCRIPTING: removeFunction
01464.596 INFO    SCRIPTING: 1
01464.596 INFO    SCRIPTING: loop
01464.596 INFO    SCRIPTING: remove

 

The first '1' is from the env.info(fId) and the rest of the lines are displayed as mist.removeFunction goes line by line.

 

Finally. I got mist.ground.patrol working.

 

I've attached the tiny test mission if you're interested in seeing a successful use of mist.ground.patrol.

 

Question; can slmod and MIST run concurrently?

 

Yeah slmod and mist work fine together. Though you should probably be using mist for any scripting functionality and leave server admin stuff to slmod.

 

I've actually been thinking of changing how the ground patrol works now that you can do it directly with the AI tasking using the goToWaypoint task. I'm waiting for the next 1.5 patch though so it is available on all DCS versions.

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

I was able to solve the problem by using loops with some true and false. Works great, but it took me a while to solve it. Fixing the removescheduleFuction would be better:)

 

Can you post a mission from where you were having the issue? With my quick test it worked fine, I'm curious about your circumstances in which it didn't.

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

Can you post a mission from where you were having the issue? With my quick test it worked fine, I'm curious about your circumstances in which it didn't.

 

Again, my lack of experience in .lua programming, made me loose my precious time... ahahha. Problem solved. I was using "local" where I shouldn´t. Just to remind other newbs at this I ll expalin my problem and the solution.

 

This is the problem....

 

function start()
[color="Red"]local [/color]myFunc = mist.scheduleFunction(message, {}, timer.getTime()+5,5)
end

start()

mist.scheduleFunction(removeFunction, {myFunc}, timer.getTime()+60)

 

 

Since I was calling the function "start()" from outside the "local myFunc" function... When I called mist.removeFunction(myFunc) it did not find such "local" variable.

 

For everynewby!! remember where and why you put locals!!!

 

so proper code is:

 

function start()
myFunc = mist.scheduleFunction(message, {}, timer.getTime()+5,5) [color="red"]-- wiithout "local"!!!![/color]
end

start()

mist.scheduleFunction(removeFunction, {myFunc}, timer.getTime()+60)


 

PS: I have lots of small scripts for the AI to do something... And this is a great tool to switch on, off without using triggers in ME, and is veriy automated.

 

For instance... I want to update my "recon aircraft" script, to switch On/off the camera. Or my EW Jamming... so now we can start and stop making emissions (that affects also our own missiles).

 

Also, if you want to make a function until certain conditions are met.


Edited by ESAc_matador
Link to comment
Share on other sites

I would be pleased to see a short tutorial in the use of mist.msgBR to display bearing and range in response to a pilot using an F10 menu choice. Specifically, how do I pass the values for vec2/vec3, and recipient to the script?

 

Example:

 

The player presses F1 to see his/her bearing and range to EnemyArmor1. As a result of a flag being set, do script:

 

mist.msgBR('EnemyArmor1', 'vec2/vec3', '30', 'recipient')

 

I think I'm on the right track for doing what I want. What might be most useful is a tutorial on how to pass the values. If I can find them, I can use them. And if I can find them for this example, that opens the door to sussing damned near anything.

 

I think I'm close...and it's driving me crazy. It's like that word you're trying to think of and it keeps flitting around the edge of your brain.

Win 10 | i7 4770 @ 3.5GHz | 32GB DDR3 | 6 GB GTX1060

Link to comment
Share on other sites

I would be pleased to see a short tutorial in the use of mist.msgBR to display bearing and range in response to a pilot using an F10 menu choice. Specifically, how do I pass the values for vec2/vec3, and recipient to the script?

 

Example:

 

The player presses F1 to see his/her bearing and range to EnemyArmor1. As a result of a flag being set, do script:

 

mist.msgBR('EnemyArmor1', vec2/vec3', '30', 'recipient')

 

I think I'm on the right track for doing what I want. What might be most useful is a tutorial on how to pass the values. If I can find them, I can use them. And if I can find them for this example, that opens the door to sussing damned near anything.

 

I think I'm close...and it's driving me crazy. It's like that word you're trying to think of and it keeps flitting around the edge of your brain.

 

 

try this



local unitPosition = Unit.getByName("yourunit"):getPosition().p -- return a Vec3
local point =  { y = unitPosition.z , x =unitPosition.x } -- THis is to put a vec2, if you want vec3 just add " z = unitPosition.y "

[i]mist.msgBR('EnemyArmor1', [b]point[/b], '30', [b]recipient[/b])[/i]-- recipient should be a table, so no " ' " needed.


 

I approach this problem with mist.getBRString and then I do myself the snippet for display the message. Try what I told you... it will probably work. however, can you put all relevant code??


Edited by ESAc_matador
Link to comment
Share on other sites

Problem solved. I was using "local" where I shouldn´t. Just to remind other newbs at this I ll expalin my problem and the solution.

 

Will not confirm nor deny I made the same mistake on making my quick test mission simply out of habit. Realized it sooner though. :smartass:

 

I would be pleased to see a short tutorial in the use of mist.msgBR to display bearing and range in response to a pilot using an F10 menu choice. Specifically, how do I pass the values for vec2/vec3, and recipient to the script?

 

Example:

 

The player presses F1 to see his/her bearing and range to EnemyArmor1. As a result of a flag being set, do script:

 

mist.msgBR('EnemyArmor1', 'vec2/vec3', '30', 'recipient')

 

I think I'm on the right track for doing what I want. What might be most useful is a tutorial on how to pass the values. If I can find them, I can use them. And if I can find them for this example, that opens the door to sussing damned near anything.

 

I think I'm close...and it's driving me crazy. It's like that word you're trying to think of and it keeps flitting around the edge of your brain.

 

Here is the wiki page on it: http://wiki.hoggit.us/view/MsgBR

 

It uses a single table for all the input values instead of multiple entries. So your syntax is incorrect.

 

The units value is a unitNameTable which is basically just a list of unit names. It can be created with mist.makeUnitTable and its multitude of input values.

 

The vec2/vec3 is a coordinate in the form of a table. Vec2 = {x,y} and Vec3 = {x,y,z} so it is a difference of 2d vs 3d. Keep in mind that the vec2 Y coordinate is the Z coordinate in vec3. The function will end up using a vec3 coordinate but it will convert it from a vec2 if needed.

 

displayTime accepts a number value. So from your sample just change it from '30' to 30. With the quote it makes it a string.

 

The recipient is really the msgFor entry and its a table in itself. You can see some examples on it here: http://wiki.hoggit.us/view/MessageAdd

 

 

The wiki has the basic syntax for all the functions in mist, so it should be enough to work out how to use the function. Not all of them have sample code 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

Gonna pull my hair out.

 

do
 mist.msgBR({
   units = mist.makeUnitTable('EA1'), -- A single red armor unit named as such
   ref = Unit.getByName('Doodenkoff'):getPosition().p, -- an L-39 I'm sitting in
   displayTime = 20,
   msgFor = {units = {'Doodenkoff'}}, --send the message to me, Doodenkoff.
 })
end

 

I checked and doublechecked the unit names in the mission editor.

 

No matter what I change in the above script, I get the identical error message in DCS.log:

 

DCS: Mission script error: : [string "C:\Users\micha\AppData\Local\Temp\DCS\/~mis0000647F"]:2141: attempt to index local 'unit' (a nil value)

stack traceback:

[C]: ?

[string "C:\Users\micha\AppData\Local\Temp\DCS\/~mis0000647F"]:2141: in function 'makeUnitTable'

[string "do..."]:3: in main chunk

Win 10 | i7 4770 @ 3.5GHz | 32GB DDR3 | 6 GB GTX1060

Link to comment
Share on other sites

Two things.

 

1. Since it is just a single unit you are testing it with then you can simply change it to units = {'EA1'}. The makeUnitTable is only really needed if you don't directly know the names of the units or want to assemble a table based on your needs. Since It is just a single unit you can just skip that step, but it still needs a table.

 

2. If Doodenkoff is the name of your player unit that will work. All scripting use of units and groups goes off of the names of the units/groups as defined in the mission editor.

 

Everything else looks right.

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

I am loading Mist at Time More (4), with more scripts at (4+n). I'd like to load Mist, first, and all my scripts and script files with separate MISSION START events, in the desired order. Is that good?

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

mist.DBs.humansByName includes coalition, and type

 

Can I also get plane, helicopter, ship, and vehicle as info?

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

I am loading Mist at Time More (4), with more scripts at (4+n). I'd like to load Mist, first, and all my scripts and script files with separate MISSION START events, in the desired order. Is that good?

 

Yeah that will work.

 

mist.DBs.humansByName includes coalition, and type

 

Can I also get plane, helicopter, ship, and vehicle as info?

 

Yeah that information is there under 'category'. It will only ever be plane or helicopters though since that whole table is defined by units set to the skill of "client" or "player" in the mission editor.

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

  • 2 weeks later...

local altitude =30000
local unitzonename = "chaffunit"
local targetname = "aircraft"
local unitsinzone = mist.getUnitsInPolygon(targetname, mist.getGroupPoints(unitzonename), altitude)
trigger.action.outText(mist.utils.tableShow(unitsinzone),20)

 

It is saying I am attepting to index global to "unitNames"(a nil value).

 

I just want to see if a detected target (I have the name of it...) is in a poligon zone.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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