Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

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!

 

Hey Feefifofum, Thanks for that! I will give it a go later on tonight. If that's all it was, then I should be misty-eyed in no time....:music_whistling:

 

M


Edited by molevitch
Problem solved! Thanks Feefifofum!

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

I'm using the clone in zone function and seeing vehicles and structures spawning inside map object buildings...

 

Is there any way around that or is it just the way it is?

 

Possibly. It depends on whether or not world.searchObjects works. It was broken for a while on Nevada, but I can't remember if that also applied to Caucuses in 1.5.

 

Basically I've kept that function to be relatively simple and it doesn't check for collisions with any buildings. As far as I remember it only checks for terrain type so it doesn't spawn any vehicle or ship where it shouldn't be.

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

Greetings gents, I've been having issues with my ground units not using the specified formation when using groupToRandomPoint. When I run this:

 

mist.groupToRandomPoint({group = 'Bravo 71', point = mist.getLeadPos('Red Target Group'), form = 'Cone', speed = mist.utils.kmphToMps (999), disableRoads = true})

 

they all just drive in file formation, no matter if I specify Cone, Vee or whatever. This worked previously, but has now stopped working since the latest 2.0 update I think. Any ideas on how to get them back in the Cone formation?

 

Cheers! Oh, and sorry if this has been taken up already.

Link to comment
Share on other sites

I've been meaning to do an update to mist for a while now and working on Viggen missions has prompted me to give mist some TLC. I've pushed a build to development branch. Plan is to get immediate issues addressed and new functions finalized and then release. I've got a scripting heavy mission for the Viggen in mind, so depending on general purpose scripting stuff I need for that mission I may have another patch for mist in the short term.

 

Develop Branch

 

 

-Added extra checks to unit spawn events

Fixed stupid errors with mist.getNextUnitId and mist.getNextGroupId

-ground vehicles spawned via mist.dynAdd will now have playerCanDrive set to true if value not present.

-Fixed typo in mist.getUnitsInPolygon

- added mist.utils.getQFE. Values returned have some error, need to figure it out, but added it for testing purposes.

- Added 2 extra values to mist.getRandPointInCircle to specify a min and max angle in degrees. Function currently assumes both are positive numbers. Need to add extra checks to it. Also need to do some testing with a change Einstein from mudspike sent me to have a better distribution of random points within the circle.

- added mist.getRandomPointInPoly. Returns a random vec2 coordinate inside a polyzone

- Added checks to getLeadPos related functions to ensure the lead unit is returned if it exists.

 

 

 

EasyEB, I'll take a look at it soon.

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 Grimes, Should mist.teleportInZone (string groupName, string zoneName, Boolean disperse, number radius) work with any warehouse?

 

I tried, it copied it then created a new one. Wondering if this was expected. I'm playing with Warehousing to see if I can move a warehouse closer to get resupply faster.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Hi Grimes, Should mist.teleportInZone (string groupName, string zoneName, Boolean disperse, number radius) work with any warehouse?

 

I tried, it copied it then created a new one. Wondering if this was expected. I'm playing with Warehousing to see if I can move a warehouse closer to get resupply faster.

 

Hmmm, it may simply work differently for static objects vs normal objects. I'll test it out.

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

Thanks, I fear Warehouses might be one of theose "special" static objects (others work) like FARPS that you can't move. But the ability to 'move' a previously connected warehouse closer as an act of moving supplies would be pretty useful for a long running mission or those rotorheads and campaign designers. So far, it looks like with two warehouses the previous distance is only in use for resupply speed and the new other one possibly is isolated and not considered in the supply route calcs.

Hmmm, it may simply work differently for static objects vs normal objects. I'll test it out.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

For some reason I didn't make the connection that you were trying to do it with a connected warehouse. Unfortunately it won't work. All of the warehouse definitions are done within the "warehouse" file in the .miz. Its just a static table of definitions loaded once the mission starts. The whole warehouse system is basically all by itself. You can only read initial values and connections, thats about all you can do with it with scripting.

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

Think of it more as a virtual zone. Because all it is doing is checking the distance between one set of units and another set of units. No actual zones are used unlike the mission editor equivalent of the function.

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

Hello,

 

Since 2.0.5 I can no longer use mist.teleportInZone for cargo objects.

 

All this flies way over my head but after comparing the files from both versions the only difference I could spot was from the db_units_ground.lua.

 

no idea if this can help but this is from the 2.0.4 db_units_ground.lua:

 

local function cargo( name, displayName, shape, rate, mass, attribute, minMass, maxMass)
   local res = {};
   
   res.Name = name;
   res.DisplayName = displayName;
   res.ShapeName = shape;
   res.Rate = rate;
   res.mass = mass;
   res.mapclasskey = "P0091000352";
   res.attribute = attribute
   res.minMass = minMass
   res.maxMass = maxMass
   res.couldCargo = true
   res.category = 'Cargo'

   
   table.insert(db.Units.Cargos.Cargo, res);
end

and that's the same part in 2.0.5:

local function cargo( name, displayName, shape, shapeDstr, life, canExplode, rate, mass, attribute, minMass, maxMass)
   local res = {};
   
   res.Name = name;
   res.DisplayName = displayName;
   res.ShapeName = shape;
   res.ShapeNameDstr = shapeDstr;
   res.life = life;
   res.canExplode = canExplode;
   res.Rate = rate;
   res.mass = mass;
   res.mapclasskey = "P0091000352";
   res.attribute = attribute;
   res.minMass = minMass;
   res.maxMass = maxMass;
   res.couldCargo = true;
   res.category = 'Cargo';

 
   table.insert(db.Units.Cargos.Cargo, res);
end

Anything you Mist wizards can do ? :(

Link to comment
Share on other sites

Hi All - Total noob when it comes to using mist beyond using other people's snippets here and there. The function i'm interested in is mist.respawnInZone

 

So far i know the following works:

 

 mist.respawnInZone('redAD', 'zone_a', false)

 

What I'd like to do is have any group with the prefix redAD be called and placed randomly in one of 4 different zones. I'd appreciate any help.

 

thx

i9 9900k - GTX 2080 Ti - MSI Z87 GD65 Mobo - 64GB HyperX Predator RGB DDR4 3200MHz - Win10 64 bit - TM Warthog w FSSB R3 mod - TrackIr 5.

 

 

 

Link to comment
Share on other sites

What I'd like to do is have any group with the prefix redAD be called and placed randomly in one of 4 different zones. I'd appreciate any help.

 

You need to iterate all the groups and run the function on it if it has 'redAD' in its name.

for name, data in pairs(mist.DBs.groupsByName) do
if string.find(name, 'redAD') then -- if redAD is part of the groups name.
	 mist.respawnInZone(name, {'zone_a', 'zone_b', 'zone_c', 'zone_d'}) -- 
end
end

The zone entry can be a table of zone names. When it is it will choose a zone at random to spawn the group in. The string.find is case sensitive, so yo need exactly 'redAD' to be somewhere in the groups name in order for it to "find" it.

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

You're the man, Grimes! This looks like it will fit the bill perfectly. I'll report back once I get a chance to test it out. Thx a bunch.

i9 9900k - GTX 2080 Ti - MSI Z87 GD65 Mobo - 64GB HyperX Predator RGB DDR4 3200MHz - Win10 64 bit - TM Warthog w FSSB R3 mod - TrackIr 5.

 

 

 

Link to comment
Share on other sites

Hi Grimes, The script works fine except that it seems to be negating the value i put in the % field (the one which determines the chance of that group spawning in the mission or not). Is there a way to get around this? The not knowing which groups will appear is just as important as their location. As it stands now, all groups are appearing no matter how low the value is. Hope this is clear. Thx again.

i9 9900k - GTX 2080 Ti - MSI Z87 GD65 Mobo - 64GB HyperX Predator RGB DDR4 3200MHz - Win10 64 bit - TM Warthog w FSSB R3 mod - TrackIr 5.

 

 

 

Link to comment
Share on other sites

Mist doesn't even read those values when it creates the database. It could be solved by a simple check, assuming you aren't respawning the units in at a later time. What I mean is you are using this to just populate the sams at the start of the mission. If that is the case you could basically just add an extra check to see if the group was spawned into the world.

 

if string.find(name, 'redAD') and Group.getByName(name) then

 

Any group that doesn't spawn in will return nothing for the Group.getByName() function call. So both string.find must find the string and the group must be spawned in order for it to be respawned.

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'm sorry but i've got no idea what to do with that code exactly. Also, I'm not respawning in anything later on in the mission.

 

Update

 

Got it to work by adding the additional line right after the other string.find, and also added another "end" based on the errors i was getting. Here's the working formulation:

 

 

for name, data in pairs(mist.DBs.groupsByName) do
       
if string.find(name, 'redAD') then -- if redAD is part of the groups name.
       if string.find(name, 'redAD') and Group.getByName(name) then
	 mist.respawnInZone(name, {'zone_a', 'zone_b', 'zone_c'}) -- 
end
end
end

 

Thx again


Edited by Invisibull
update

i9 9900k - GTX 2080 Ti - MSI Z87 GD65 Mobo - 64GB HyperX Predator RGB DDR4 3200MHz - Win10 64 bit - TM Warthog w FSSB R3 mod - TrackIr 5.

 

 

 

Link to comment
Share on other sites

It was more meant to replace that line rather than adding a new one. You don't need to do the string.find twice.

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 dont konw why, but I am having issues with this function...

 

mist.teleportInZone('rus1', {'1', '2'}, true, 150). I have used it thousand times, and now it says that #1 parameter missed, in .mist line 3342, which refers to this.

 

zone = trigger.misc.getZone(zone[math.random(1, #zone)])


Edited by ESAc_matador
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...