Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

How can i use the CloneInZone so the aircraft group keeps its current task?

 

Basically you have to get information from the group that was cloned for their task and then assign it to the new group. When you use mist.cloneInZone() it returns the table that was used to spawn the group, one of those entries is "name" and will be generated via the script. You may need to schedule the mist.goRoute() function to occur at a slightly later time due assigning a task immediately after a group spawned can cause crashes. Keep in mind though that the route will be identical and the AI will fly from wherever they spawned at to the starting waypoint that has been assigned. You can always modify the first waypoint in the newRoute table to match the current position of the first unit in newGroup.

 

local newGroup = mist.cloneInZone('whatatever'..).name

local newRoute = mist.getGroupRoute('whatever', true)

mist.goRoute(newGroup, newRoute)

 

I am doing a script where I first do some teleports and spawns and then I use mist.makeUnitTable({'[red]'}). It does not work... and may be it is because since I created new units through the teleport...

 

How to get the list of the current units??

 

Shouldn't matter how the groups are spawned. Are you doing it as part of the same function call? As in...

 

mist.teleportInZone('bla', 'blaa')

local redTeam = mist.makeUnitTable({'[red]'})

 

If so that could be the problem. The DBs update pretty quick, but it isn't instant.

 

Curious about your situation- if you're teleporting units it should just move the same unit. I'm having some issues with some "cloned" groups- which are different (I think) since they are actually generated dynamically and are out of reach from the mission scripting engine.

 

Clone groups are only accessible by the scripting engine while respawned and teleported units can be seen by triggers due to the unitIds and groupIds matching. Respawn, clone, and teleport all eventually use coalition.addGroup() which is how units are dynamically spawned. The difference is where and what data is grabbed from the group. Respawn will respawn the entire group. Teleport moves only the units that are currently alive. Clone does the same thing as respawn, but removes unitId, unitNames, groupId, and groupName from the table and relies on mist.dynAdd to repopulate that data. As long as those values are unique no other unit will be removed from the simulation because its been "overwritten"

 

 

Anything abstract / not working about the "group patrol route" function?

 

Does it need to be entered as an overall trigger or as a last waypoint advanced entry?

 

Edit: Okay well now that I'm at the computer- I've tried both and both crash out.

 

It has caused crashes before for unknown reasons. What map were you doing it on? BTW, it should work fine if assigned on either the first or last WP since I believe it just reassigns the route anyways.

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

Basically you have to get information from the group that was cloned for their task and then assign it to the new group. When you use mist.cloneInZone() it returns the table that was used to spawn the group, one of those entries is "name" and will be generated via the script. You may need to schedule the mist.goRoute() function to occur at a slightly later time due assigning a task immediately after a group spawned can cause crashes. Keep in mind though that the route will be identical and the AI will fly from wherever they spawned at to the starting waypoint that has been assigned. You can always modify the first waypoint in the newRoute table to match the current position of the first unit in newGroup.

 

local newGroup = mist.cloneInZone('whatatever'..).name

local newRoute = mist.getGroupRoute('whatever', true)

mist.goRoute(newGroup, newRoute)

 

Thanks! Will try this approach. :thumbup:

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

 

local newGroup = mist.cloneInZone('whatatever'..).name

local newRoute = mist.getGroupRoute('whatever', true)

mist.goRoute(newGroup, newRoute)

 

Ok, i tested the following code. Doesnt work. But i do wonder if i understood your instructions correctly. How does this look to a you?

 

DOESNT WORK

missionCommands.addCommand("Spawn TEST",_airtargets,function() 
local newGroup = mist.cloneInZone('1xMiG-21', {'test'})
local newRoute = mist.getGroupRoute('1xMiG-21', true)
trigger.action.outTextForCoalition(coalition.side.BLUE, "TEST", 5)
mist.goRoute(newGroup, newRoute)
end,nil)

 

EDIT!:

Ok hold your horses. The following code seem to work! The only issue is like you mentioned Grimes, that the aircraft goes to the initial position of the template aircraft.

 

WORKS!

missionCommands.addCommand("Spawn TEST2",_airtargets,function() 
do
local gp = mist.cloneInZone('1xMiG-21', 'test')
local newRoute = mist.getGroupRoute('1xMiG-21')
mist.goRoute(gp.name, newRoute)
end
end,nil)


Edited by Rivvern

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

It has caused crashes before for unknown reasons. What map were you doing it on? BTW, it should work fine if assigned on either the first or last WP since I believe it just reassigns the route anyways.

 

It was on 1.5-

 

I should mention the game didn't crash- per se... it just kicked an error message.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

I should mention the game didn't crash- per se... it just kicked an error message.

 

That isn't the same thing. Usually what that means is it is a syntax error or a value passed was nil. Game crash, is well the game crashes to desktop and usually gives you the windows error box associated with programs that have crashed. A lua error you can just click "ok" to continue and depending on what may be causing that error the entire script may simply just stop, or that specific part of the script will keep erroring out periodically.

 

 

EDIT!:

Ok hold your horses. The following code seem to work! The only issue is like you mentioned Grimes, that the aircraft goes to the initial position of the template aircraft.

 

Yeah, so you can modify the new route there...

 

newRoute.[1].x = gp.units[1].x

newRoute.[1].y = gp.units[1].y

 

 

Don't forget the true as the second value of mist.getGroupRoute as that defines whether or not it returns the groups actual tasks assigned to each WP. Without it the group will just follow the flight plan and won't attack anything.


Edited by Grimes

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

Not able to reproduce it on my end. Can you post an example of the triggers or scripting function you are using to call it? Or even the mission?

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

Grimes. Im trying to figure out what you mean but not having any luck. Where do i place the

newRoute.[1].x = gp.units[1].x
newRoute.[1].y = gp.units[1].y

 

 

This gives me an error expecting a name at the newRoute line.

missionCommands.addCommand("Armed Speedboat",_seatargets,function() 
do
local gp = mist.cloneInZone('armedspeedboat', 'ships1')
local newRoute = mist.getGroupRoute('armedspeedboat', true)
newRoute.[1].x = gp.units[1].x
newRoute.[1].y = gp.units[1].y
mist.goRoute(gp.name, newRoute)
end
end,nil)

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Whoops, the dot between newRoute and [1] needs to be removed.

 

newRoute[1].x = gp.units[1].x

newRoute[1].y = gp.units[1].y

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

Everything seem to work fine.

 

Here is the code if anyone is interested.

 

Use this in your lua file and then load it after MIST in the mission.

Be sure to set up the units and trigger zones to match the lua file..

 

If someone got a better idea, please let me know.

Note. I did not set up a delay for the newRoute, mostly because i dont know how. I havent encountered any issues so far.

 

For creating F10 menus and sub menus with spawnable units.

--creating menu
local _spawn = missionCommands.addSubMenuForCoalition(coalition.side.BLUE, "Spawn")
local _airtargets = missionCommands.addSubMenuForCoalition(coalition.side.BLUE, "Air targets", _spawn)
local _seatargets = missionCommands.addSubMenuForCoalition(coalition.side.BLUE, "Sea targets", _spawn)

--spawnables
--_airtargets
missionCommands.addCommand("Spawn 1xMiG-21",_airtargets,function() 
do
local gp = mist.cloneInZone('1xMiG-21', {'zone1','zone2','zone3','zone4'})
local newRoute = mist.getGroupRoute('1xMiG-21', true)
newRoute[1].x = gp.units[1].x
newRoute[1].y = gp.units[1].y
mist.goRoute(gp.name, newRoute)
trigger.action.outTextForCoalition(coalition.side.BLUE, "MiG-21 detected", 5) 
end
end,nil)

--_seatargets1
missionCommands.addCommand("CV 1143.5 Admiral Kuznetsov",_seatargets,function() 
do
local gp = mist.cloneInZone('kuznetsov', {'ships1','ships2','ships3'})
local newRoute = mist.getGroupRoute('kuznetsov', true)
newRoute[1].x = gp.units[1].x
newRoute[1].y = gp.units[1].y
mist.goRoute(gp.name, newRoute)
trigger.action.outTextForCoalition(coalition.side.BLUE, "CV 1143.5 Admiral Kuznetsov detected", 5) 
end
end,nil)

 

Credits to Grimes!

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

I've read a few older threads on the issue- and I'm sorry if I missed mention of it somewhere... but is there a clearly defined way to randomly spawn a static / structure in a defined zone using MIST?

 

Not sure if it answers you question but Im spawning Cargo this way. Not sure if its really a Static item though.

 

mist.cloneInZone('cargo_1000', {'pickzone1'}, true)

  • Like 1

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Thanks riv. Cargo is in statics- structures might be different. I haven't had a chance to dork with it yet.

 

 

EDIT: IT WORKED!

 

Okay so now if you wanted to spawn that structure with vehicles from a separate group- can you do that? Reason being the structure will have defenses spawn in the same zone (ideally).


Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

Is there a way to detect laser in a zone or something similar with Mist? Trying to get back into mission building and I have bigger ideas than brains :D

 

As far as I know you can only do it with lasers created with the scripting engine via the spot class. Lasers emitting from player aircraft, AI, or CA vehicles is simply not accessible.

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

  • ED Team
As far as I know you can only do it with lasers created with the scripting engine via the spot class. Lasers emitting from player aircraft, AI, or CA vehicles is simply not accessible.

 

What about smoke markers launched from vehicles in CA?

64Sig.png
Forum RulesMy YouTube • My Discord - NineLine#0440• **How to Report a Bug**

1146563203_makefg(6).png.82dab0a01be3a361522f3fff75916ba4.png  80141746_makefg(1).png.6fa028f2fe35222644e87c786da1fabb.png  28661714_makefg(2).png.b3816386a8f83b0cceab6cb43ae2477e.png  389390805_makefg(3).png.bca83a238dd2aaf235ea3ce2873b55bc.png  216757889_makefg(4).png.35cb826069cdae5c1a164a94deaff377.png  1359338181_makefg(5).png.e6135dea01fa097e5d841ee5fb3c2dc5.png

Link to comment
Share on other sites

If it produces a shot event in the logs then it is trackable via scripting. So in terms of marking target type weapons then you have illumination rockets/bombs and smoke rockets. Combined Arms smoke is kind of special because I'm pretty sure its just mimicking a trigger.action.smoke() type command where-ever the player's camera is looking at.

 

Suffice to say I wish the scripting engine had access to target pod orientation, lasing information, orientation of any on board search lights, or a more advanced way to accept commands from players than just an F10 radio menu. But we don'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

MIST/CTLD not loading at mission start

 

Dear All,

 

I have just started to get into this wonderful world of advanced mission building and am very excited about MIST/CTLFD/MOOSE.

 

However, when I set up a mission in ME and use triggers to call the mist.lua and ctld.lua, they do not appear to be loading. I get an error dialog "Mission Script Error" saying things like "unexpected symbol next to '<'".

 

This only happens when I build it myself in ME. If I download a .miz file from ED Forums or similar, the mission loads correctly. If I build my own mission from scratch, calling mist.lua from a folder on my computer (obvs), the mission will load, but within 2 seconds (TIME MORE, 2) the error messages pop up, presumably saying the mist.lua is not loaded.

 

I have looked around a lot for help on this forum, but have not yet found a solution. Any suggestions would be greatly appreciated. Its the same for both 1.5 and 2.05.

 

Frustrated!

 

M.:mad::cry:

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

Can you post a mission file where this error occurs? It would be the easiest way to see what is going wrong.

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 file where this error occurs? It would be the easiest way to see what is going wrong.

 

Thanks Grimes,

 

Here is a sample

 

mi8 transport test.miz for 1.5. The mission runs, but no mist or ctld....

 

Very basic to test problem....

 

I get this. https://forums.eagle.ru/attachment.php?attachmentid=156792&stc=1&d=1486475291

 

Thank you for having a look.

 

Yours

 

Molevitch:helpsmilie:

Molevitch-mission-script-error.thumb.jpg.145646e609ad4c0cb57343d4539ce5a1.jpg


Edited by molevitch

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Link to comment
Share on other sites

  • ED Team
If it produces a shot event in the logs then it is trackable via scripting. So in terms of marking target type weapons then you have illumination rockets/bombs and smoke rockets. Combined Arms smoke is kind of special because I'm pretty sure its just mimicking a trigger.action.smoke() type command where-ever the player's camera is looking at.

 

Suffice to say I wish the scripting engine had access to target pod orientation, lasing information, orientation of any on board search lights, or a more advanced way to accept commands from players than just an F10 radio menu. But we don't.

 

Yeah, I feature requested that that smoke get added to be detectable in a zone, so crossing my fingers, just wasnt sure if there was some MIST magic I could use for lasers or other JTAC type things.

64Sig.png
Forum RulesMy YouTube • My Discord - NineLine#0440• **How to Report a Bug**

1146563203_makefg(6).png.82dab0a01be3a361522f3fff75916ba4.png  80141746_makefg(1).png.6fa028f2fe35222644e87c786da1fabb.png  28661714_makefg(2).png.b3816386a8f83b0cceab6cb43ae2477e.png  389390805_makefg(3).png.bca83a238dd2aaf235ea3ce2873b55bc.png  216757889_makefg(4).png.35cb826069cdae5c1a164a94deaff377.png  1359338181_makefg(5).png.e6135dea01fa097e5d841ee5fb3c2dc5.png

Link to comment
Share on other sites

Hi molevitch!

I was having this same problem for the longest time and thought I was just a terrible idiot...

Turns out in my case it was a bit of a questionable user interface at Github that was causing my problems.

 

If you are in the main project folder view, and right click on, say CTLD.lua and hit save as; a window will pop up that says you're saving CTLD.lua.

 

Unless you open the script in a text editor, everything will look normal until you load the mission and DCS starts spitting out errors. The issue is, even though the "save as" window is showing you CTLD.lua, what you're actually getting is the script's file plus what appears to be a bunch of html related to the github interface.

 

From the main project view, left click the individual file to open it inside of GitHub. There will be a button at the top of the script that says "Raw"

 

Right click on the "Raw" button and hit save as, and it will give you a clean version of the script without all the HTML crap and should work properly in your missions!


Edited by feefifofum
  • Like 1
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...