Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Thanks Grimes, I appreciate you looking at it for me.

I changed the offending Mission Start events to Once and added a Time More of 10 seconds, then to 100 seconds, but the same error showed. I changed the loading of Mist from a Mission Start to Once, Time More (90), but that did not help either. The latest version of the mission is attached. (BTW, there are 28 error notices coming up and 28 events that are using the function.)

 

If you have any other ideas please let me know and I will try them.

Do you still think this is a Mission Start bug?

 

---

edit --> the reason I ask that last part is, should I add this to the DCS World's ME Bugs reports?

Ira'dib 255P1e.zip


Edited by Wrecking Crew

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

It looks like there are a few things going on. One being a bug in the game, another being mist not accounting for that bug, and what looks like a slight syntax error on your end which ultimately kicks the problem off.

 

I only modified one trigger to test but the pattern looks to be repeated. So your code is

 

mist.flagFunc.units_in_zones{ 
   units = {'[blue],[plane]'}, 
   zones = {'60 SA-2 Zone'}, 
   flag = 96027,
   req_num = 2,
   toggle = true,    
}

 

From the looks of things you are wanting to only check for blue planes in that zone? It is building a list of all blue objects and all planes. If you remove the comma, it will only add all blue planes to the list. '[blue][plane]'

 

Now for the ED and mist bug. Because it was looking for all blue objects that includes all static objects, specifically the farp object. The farp object is a bit bugged at the moment (ED's bug) in that it basically returns something but not what it should. The mist bug is that it checks for the existence of anything and assumes that it would be a full object, which it attempts to run a function on that doesn't exist. Hence the error. I'm not sure why it wasn't occurring in 2.5.5 but started to in 2.5.6. If I had to guess I'd say that in 2.5.5 the check of "returning anything" failed in 2.5.5 but is succeeding in 2.5.6.

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

Taking out the comma fixed all the of error popups!

And, I went back to using Mission Start for the 28 events.

 

Your help is really, really appreciated!

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

Just to report but I think it's minor issue.

 

I just had trouble with DCS freezing while testing 1 mission building. I nevertheless tried all the usual "crash" suspects, but it was a command synthax that worked with previous DCS version.

 

I used : mist.groupToPoint('Groupname', 'Zonename', 'on road', nil, 60, true) and mission systematically crashed (DCS freeze - to the point only reboot can work) after couple of minutes when spawning / auto-destroying groups that trigger this fonction.

Now I use : mist.groupToPoint('Groupname', 'Zonename', 'On Road', 60) zero problem.

 

Just in case someone encounter this DCS freeze in an other case (so no log, no lua error msg) - because I spent lot of time to find the issue, it can be a synthax obsolete or that became unstable now ? (Mist 4.3.74)

Link to comment
Share on other sites

we use mist and ctld but have an issue

so the troop pickzone all works fine no dramas there

the problem is logistics1 for example

when you reopen the map its been renamed by the game to ammo hash 001 for example so we placed another one called logistics2 and same thing

anyoen else sen this and or found a fix? cos whilst its doing this we cant use our logistics tents

just says your not close enough to a logistics point yet im parked right next to it and inthe mission builder we did name it logistics1

 

also embark to transport appears not to be working for ordinary pre placed troops now you hit f7 and no option to embark to transport comes up just f11 or f12

any fixes for any of the above/thx

Link to comment
Share on other sites

Hey guys, I've got a little script to randomly spawn a few subs, but I can't get them to get SetInvisible true.

 

Script works in all other aspects, they just don't seem to inherit the invisible setting. Any ideas?

 

Still on 2.5.5

 

function SpawnRandomSub()
	
	local zone = trigger.misc.getZone("SUB")

	local subTable = {}
	local subNumber = mist.random(2,4)
	
	for k = 1, subNumber do
	
	repeat --Find a random spot of WATER within the large AO SUB
			unitSpawnZone = mist.getRandPointInCircle(zone.point, zone.radius)
	until land.getSurfaceType(unitSpawnZone) == land.SurfaceType.WATER
	
	
		local units = {}
										
			table.insert(units,
			{
				["x"] = unitSpawnZone.x,
				["y"] = unitSpawnZone.y,
				["type"] = 'KILO',
				["name"] = 'I-SUB #00'..k,
				["heading"] = mist.random(359),
				["skill"] = "Random",
				["route"] = {
                                   ["points"] = 
                                   {
                                       [1] = 
                                       {
                                           ["task"] = 
                                           {
                                               ["id"] = "ComboTask",
                                               ["params"] = 
                                               {
                                                   ["tasks"] = 
                                                   {
                                                       [1] = 
                                                       {
                                                           ["enabled"] = true,
                                                           ["auto"] = false,
                                                           ["id"] = "WrappedAction",
                                                           ["number"] = 1,
                                                           ["params"] = 
                                                           {
                                                               ["action"] = 
                                                               {
                                                                   ["id"] = "SetInvisible",
                                                                   ["params"] = 
                                                                   {
                                                                       ["value"] = true,
                                                                   }, -- end of ["params"]
                                                               }, -- end of ["action"]
                                                           }, -- end of ["params"]
                                                       }, -- end of [1]
                                                   }, -- end of ["tasks"]
                                               }, -- end of ["params"]
                                           }, -- end of ["task"]
                                       }, -- end of [1]
                                   }, -- end of ["points"]
                               }, -- end of ["route"]
			})
								
		mist.dynAdd({country = 'Iran', category = 3, name = 'I-SUB #00'..k , hidden = false, units = units }) --Create and spawn the group
	
		mist.groupRandomDistSelf ('I-SUB #00'..k, 100000, nil, mist.random(1,359), mist.random(8,20)) 

	end
end		
SpawnRandomSub()

OPERATION DUGONG - RANDOM SUB.lua

Link to comment
Share on other sites

Using this to send my JTAC as invisible and immortal :

 

local jtac = Group.getByName('JTAC (137 AM)')

local target = Group.getByName('Red Target Group'):getID()

local Orbit = {

id = 'Orbit',

params = {

pattern = 'Circle',

point = unitSpawnZone,

altitude = 5000

}

}

jtac:getController():pushTask(Orbit)

 

local task = {

id = 'FAC_EngageGroup',

params = {

groupId = target,

weaponType = 2956984318,

frequency = 137,

designation = 'Laser',

datalink = true,

},

}

jtac:getController():pushTask(task)

 

local SetInvisible = {

id = 'SetInvisible',

params = {

value = true

}

}

jtac:getController():setCommand(SetInvisible)

 

local SetImmortal = {

id = 'SetImmortal',

params = {

value = true

}

}

jtac:getController():setCommand(SetImmortal)

i9 9900k, 64 Go RAM, RTX 4090, Warthog HOTAS Throttle & Stick, Saitek Combat Rudder, MFD Cougar, Trackir 5 Pro, Multipurpose UFC and Oculus Rift S (when I want some VR),

http://www.twitch.tv/zarma4074 /  https://www.youtube.com/user/Zarma4074 

 

Copy-of-DCS-A-10C-User-Bar-CMR-ConvertImage.jpg

Link to comment
Share on other sites

  • 3 weeks later...

That's because the mist script has not been loaded.

Either you didn't load it in a trigger, loaded it too late (after the script you showed us), loaded it wrong (bad path) or an error occured while loading (see dcs.log)

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

MIST seems load because "AddSubmenu" function work fine, only "Respawn" not work :(

 

 

The error message you showed said (translated to human language ^^) "mist is not loaded".

 

 

Could you attach your mission file, I'll test it and tell you what's wrong.

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

Hi,

I tried your mission but I have no F10 radio menu.

Are you sure this mission is not missing anything else ? Or maybe I have to do something ? Occupy a specific slot ?

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

Hello, world of DCS scripting ^^

 

 

I think I found either a bug or something really weird in mist.

 

 

I've got a test mission set up to demontrate this behavior, attached.

 

 

If I use mist to respawn an aircraft group (late-activated or not), the :getUnits() method returns an empty table, but the group is actually alive with all its units.

 

 

Can anyone help ?

test.miz

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

Hello, world of DCS scripting ^^

I think I found either a bug or something really weird in mist.

I've got a test mission set up to demontrate this behavior, attached.

If I use mist to respawn an aircraft group (late-activated or not), the :getUnits() method returns an empty table, but the group is actually alive with all its units.

Can anyone help ?

 

 

Self-quoting, the narcissim of the internet-era ;)

 

 

More seriously, this is probably due to the way Mist spawns units in DCS.

I tried with Moose, which does not respawn the group but instead create a new one, considering the first group as a template ; it works, but it's not possible to actually respawn (i.e. make the group disappear, and reappear as if new, at its original location).

Anything ?

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

Is there a way to show the name of the player activating a script via the F10 menu ??

 

In a round-a-bout way yes, but it can be limiting. If you only add commands at a group level and then for the arguments embed the groupId you will know which group selected it. If you have more than 1 client per group there is no way to figure it out beyond that aside for figuring out which units are alive and guessing, or by making a sub-category meant for each player.

 

local function whateverFunction(args)

trigger.action.outTextForGroup(args.id, 'Hello", 20)

end

 

missionCommands.addCommandForGroup(5, Command for GroupId 5, nil, function whateverFunction, {id = 5})

 

For the actual player name you have to use mist.DBs.groupsById, then get the group name, get units, and getPlayerName() on the unit.

 

If I use mist to respawn an aircraft group (late-activated or not), the :getUnits() method returns an empty table, but the group is actually alive with all its units.

 

 

Can anyone help ?

 

At that exact instant the game is accessing the old group. In my attached screenshot I made an extra trigger to run 1 second after the respawn code executes, it correctly returns the group size.

 

It is a factor of how the coalition.addGroup code works, which both mist and moose use. The mist respawn group uses the original group as a template but exploits the fact that if certain parameters match existing parameters then the original group will be overwritten. In a split second the original group is removed and a new one takes its place. Due to how code on the back-end, and within mist works, not everything gets updated at exactly the same time, so sometimes you have to wait a moment to run certain code on objects that get spawned.

getGroup_func.jpg.e7cdc591f1bcf9cdf1f8532d04c09d09.jpg

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 !!

 

My script is already 5000+ lines long so I guess I won't try to add this functionality.

 

Have a nice day !

i9 9900k, 64 Go RAM, RTX 4090, Warthog HOTAS Throttle & Stick, Saitek Combat Rudder, MFD Cougar, Trackir 5 Pro, Multipurpose UFC and Oculus Rift S (when I want some VR),

http://www.twitch.tv/zarma4074 /  https://www.youtube.com/user/Zarma4074 

 

Copy-of-DCS-A-10C-User-Bar-CMR-ConvertImage.jpg

Link to comment
Share on other sites

At that exact instant the game is accessing the old group. In my attached screenshot I made an extra trigger to run 1 second after the respawn code executes, it correctly returns the group size.

 

It is a factor of how the coalition.addGroup code works, which both mist and moose use. The mist respawn group uses the original group as a template but exploits the fact that if certain parameters match existing parameters then the original group will be overwritten. In a split second the original group is removed and a new one takes its place. Due to how code on the back-end, and within mist works, not everything gets updated at exactly the same time, so sometimes you have to wait a moment to run certain code on objects that get spawned.

 

Hi Grimes, thanks for your answer !

Your explanation is clear and interesting, I'm learning stuff, and I like that.

 

 

However, in the mission I attached the check() function is called automatically after spawn (which may cause the effects you described), but also in a radio menu command that can be triggered at will.

And if I run this command say, 10 seconds later, the check() function has the same output as when it is ran right after the spawn :

 

Pczfh6y.jpg

 

You can try this by yourself if you want, this is perfectly reproduceable.

 

I may have overlooked something, but I think that the way MiST spawns the groups make DCS behave weird afterwards.

 

Could you have a look, please, you're the only one I know with that much experience of DCS scripting ^^ :helpsmilie:

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

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...