Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

I found out that having "\n" in the string when using mist.utils.dostring() fails the execution of the code because of improperly ending string. It the behavior is like intended then maybe add mention of this problem in the wiki. The explanation of the function in the wiki is also a bit messy ("... If false, then this value will be the compilation error. ...", which value?).

 

It needs to be a block of code in a string format and it needs to follow the same syntax rules as lua.

 

mist.groupRandomDistSelf('group1', 1000)

is the same as

mist.utils.dostring([[mist.groupRandomDistSelf('group1', 1000)]])

 

 

You don't really need to have line breaks in it either.

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 trying to use textOut with linebreaks in a very long string to break it to multiple lines. Is there some other way to do this besides using linebreaks? I was able to find a work around that doesn't require that kind of formatting but I think it would be useful to be able to do that if it's possible. The same line runs without problems without the dostring.

DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community

--------------------------------------------------

SF Squadron

Link to comment
Share on other sites

Hi,

 

I need a little help understanding one thing: the function below export some info for every point of the route of any group in a mission, and create a .txt file in the Logs folder in "saved games" directory for any group.

 

I obviously plan to limit this export only to the slot with skill = client, but in the meantime I have another problem.

 

The coordinate exported are different from what I see in the editor. For example, this point:

 

x,y = -284544.28571429 ; 685054.57142857

 

is located exatcly on the head of rwy 26 of Kutaisi. And the effective coordinates are:

 

lat, long = N 42° 10.768' ; 42° 29,762'

 

But this is what I get from the export:

 

lat, long = 42 34.08790'N ; 34 12.74865'E

 

What is my error?

 

 

 

--flightplan export script

 

do

local fName = "Groupdata.txt"

local f = io.open(lfs.writedir() .. "Logs/" .. fName, "w")

do

f:write("Versione;groupId;category;Coalition;group_name" .. "\n")

end

 

if f then

local fileString

for coalitionID,coalition in pairs(env.mission.coalition) do

for countryID,country in pairs(coalition["country"]) do

for attrID,attr in pairs(country) do

if (type(attr)=="table") then

for groupID,group in pairs(attr["group"]) do

if (group) then -- aggiungi qui la selezione

fileString = "Version11" .. ";"

.. groupID .. ";"

.. attrID .. ";"

.. coalitionID .. ";"

.. group.name

.. "\n"-- ecc ecc

f:write(fileString)

 

-- ROUTE POINTS EXPORT

-- if group has route and points table

if group["route"] and group["route"]["points"] then

-- open route file here

local routeFile = io.open(lfs.writedir() .. "Logs/Groupdata_Route_" .. group.name .. ".txt", "w");

-- cycle between route table elements (aka route points)

do

routeFile:write("Group_name;pointId;coord;Name;ETA;ETA_locked;speed;speed_locked;type" .. "\n")

end

 

for pointId,point in pairs(group["route"]["points"])

do

local x = point.x;

local y = point.y;

 

-- TODO check XY -> XZ for inversion

 

local lat, lon = coord.LOtoLL(point);

 

local coord = mist.tostringLL(lat, lon, 3)

 

routeFile:write(

group.name .. ";" ..

pointId .. ";" ..

coord .. ";"

)

 

-- don't know if name is always present in the table, safety check

if (point["name"]) then

routeFile:write(point["name"])

end

routeFile:write(";")

 

-- don't know if ETA is always present in the table, safety check

if (point["ETA"]) then

routeFile:write(point["ETA"])

end

routeFile:write(";")

 

if(point["ETA_locked"]) then

routeFile:write("1;")

else

routeFile:write("0;")

end

 

-- don't know if speed is always present in the table, safety check

if (point["speed"]) then

routeFile:write(point["speed"])

end

routeFile:write(";")

 

if(point["speed_locked"]) then

routeFile:write("1;")

else

routeFile:write("0;")

end

 

routeFile:write(point["type"] .. "\n")

 

end

routeFile:close()

end

-- ROUTE POINTS EXPORT END

 

end

end

end

end

end

f:close()

end

end

end

 

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

It's likely that that I inadvertently had multiple quotation marks in one piece of string as a result of concatenation that caused the error. I already changed the code to be completely different so I can't test to verify but it's likely the line breaks weren't the issue.

DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community

--------------------------------------------------

SF Squadron

Link to comment
Share on other sites

What is my error?

 

for pointId,point in pairs(group["route"]["points"])

do

local x = point.x;

local y = point.y;

 

-- TODO check XY -> XZ for inversion

 

local lat, lon = coord.LOtoLL(mist.utils.makeVec3(point))

 

local coord = mist.tostringLL(lat, lon, 3)

 

routeFile:write(

group.name .. ";" ..

pointId .. ";" ..

coord .. ";"

)

  • Like 1

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Thanks! It works :).

  • Like 1

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

Hello guys, played a bit with mist.ground.patrol last night and noticed a strange thing (it may be the intended functionality but that I can't say myself). I have assigned a simple route (4WP) to a M113. On the last WP from the route I have added mist.ground.patrol('myUnit'). On WP 2 I have added trigger.action.outtext("WP reached",10) via run script under perform commands in advanced waypoints cmds. Unit is patroling alright but the message is printed only on the first pass through the route. Is that anything wrong I am doing?

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

Having problems with teleportInZone

 

Under a couple of scenarios, when I use teleportInZone everything works fine until I exit the mission. Then I get a game crash. Sorry, no crash logs are created. My function call just looks like:

 

mist.teleportInZone ("My Group", "My Zone").

 

 

 

Scenario 1: I teleport an AI air group into a zone and then let the group land at any airport. The group lands fine but the game crashes when I exit the mission.

 

Scenario 2: I teleport an AI air group into a zone and then I jump into one of the planes. Again, this works fine until I exit the mission.

 

I noticed something in the debrief below that I thought looked odd. Before the teleport, the initiatorMissionID is a number. Specifically, 42. After the teleport, the initiatorMissionID becomes "Pilot #001". Might this have something to do with the crash?

 

[1] =

{

type = "mission start",

t = 37800,

}, -- end of [1]

 

[2] =

{

type = "took control",

t = 37800,

}, -- end of [2]

 

[3] =

{

type = "engine shutdown",

initiator = "Pilot #001",

place = "Krasnodar-Center",

t = 37811.2,

initiatorMissionID = "42",

}, -- end of [3]

 

[4] =

{

type = "engine startup",

initiator = "Pilot #001",

place = "Krasnodar-Center",

t = 37824.5,

initiatorMissionID = "42",<-------- BEFORE TELEPORT

}, -- end of [4]

 

[5] =

{

type = "engine startup",

t = 37830.901,

initiatorMissionID = "Pilot #001", <-------- AFTER TELEPORT

initiator = "Pilot #001",

}, -- end of [5]


Edited by kontiuka
Link to comment
Share on other sites

I'm just starting with Mist so I most likely got something wrong (I'm also new to Lua)... But just in case, is there a bug in mist.groupToRandomZone?

 

function groupIsDead(groupName)
local groupLife = 0;
local i = 1;
local group = Group.getByName(groupName);

while group:getUnit(i) do
	groupLife = groupLife + group:getUnit(i):getLife();
	i = i + 1;
end;

return (groupLife == 0);
end;

function init()
mist.groupToRandomZone("MyGroup", {"TargetArea"}, AI.Task.VehicleFormation.LINE_ABREAST, 045, 80);
end;

DeathHandler = {}

function DeathHandler:onEvent(event)
   if event.id == world.event.S_EVENT_DEAD then
	local unit = event.initiator;
	local groupName = unit:getGroup():getName();
	
	if groupIsDead(groupName) then
		trigger.action.outText("Group " .. groupName .. " is dead. Respawning...", 10);
		mist.respawnGroup(groupName, 10);
		mist.groupToRandomZone(groupName, {"TargetArea"}, AI.Task.VehicleFormation.LINE_ABREAST, 045, 80);
	end
   end
end

world.addEventHandler(DeathHandler);

init();

 

This code works the first time (so init(); works). But after group's death, it will respawn, starts moving and then crashes. It's not instant crash on respawn but takes a couple of seconds. Anything obvious wrong?

Link to comment
Share on other sites

kontiuka

 

I am getting the same kind of problem with mist.teleportinzone and mist.respawninzone. DCS crash when I try to go back to the editor

 

I used to have the same problem with dynadd in mist 3.1 but since 3.2 dynadd works without crashing.

 

also with the function

 

mist.scheduleFunction(mist.respawnInZone,{'Armor_1', {'zone_1','zone_2', 'zone_3'} , true , 150},timer.getTime() + 10)

 

for some reason the group only respwn in zone_1. I don t know if it is a problem with me not knowing to program or the random number generator or a bug


Edited by Prof_hilactic
Link to comment
Share on other sites

kontiuka

 

I am getting the same kind of problem with mist.teleportinzone and mist.respawninzone. DCS crash when I try to go back to the editor

 

I used to have the same problem with dynadd in mist 3.1 but since 3.2 dynadd works without crashing.

 

also with the function

 

mist.scheduleFunction(mist.respawnInZone,{'Armor_1', {'zone_1','zone_2', 'zone_3'} , true , 150},timer.getTime() + 10)

 

for some reason the group only respwn in zone_1. I don t know if it is a problem with me not knowing to program or the random number generator or a bug

I am also using 3.2 and I've tried dynAdd but I still get the game crash. All I'm doing is the following:

 

local groupData = mist.getCurrentGroupData ("New Airplane Group")

groupData.task = "CAS"

mist.dynAdd(groupData)

 

Would you mind showing me how you're using dynAdd? Thanks much.

Link to comment
Share on other sites

Hello guys, played a bit with mist.ground.patrol last night and noticed a strange thing (it may be the intended functionality but that I can't say myself). I have assigned a simple route (4WP) to a M113. On the last WP from the route I have added mist.ground.patrol('myUnit'). On WP 2 I have added trigger.action.outtext("WP reached",10) via run script under perform commands in advanced waypoints cmds. Unit is patroling alright but the message is printed only on the first pass through the route. Is that anything wrong I am doing?

 

The function doesn't grab the tasks assigned to the route. So what its doing is the group is following its normal route, and then at the end mist.ground.patrol() grabs all of the route points and effectively creates a new route.

 

Under a couple of scenarios, when I use teleportInZone everything works fine until I exit the mission. Then I get a game crash. Sorry, no crash logs are created. My function call just looks like:

 

mist.teleportInZone ("My Group", "My Zone").

 

Scenario 1: I teleport an AI air group into a zone and then let the group land at any airport. The group lands fine but the game crashes when I exit the mission.

 

Scenario 2: I teleport an AI air group into a zone and then I jump into one of the planes. Again, this works fine until I exit the mission.

 

 

I'll have to do some testing. The initiatorMissionID is created by the debrief logs and as far as I know mist has no direct control over it.

 

I'm just starting with Mist so I most likely got something wrong (I'm also new to Lua)... But just in case, is there a bug in mist.groupToRandomZone?

 

This code works the first time (so init(); works). But after group's death, it will respawn, starts moving and then crashes. It's not instant crash on respawn but takes a couple of seconds. Anything obvious wrong?

 

Most likely AI.Task.VehicleFormation.LINE_ABREAST is the cause. For some reason the scripting engine uses "Rank" instead of line abreast. The function accepts a string of the formation type, but not the enumerator of the vehicle formation. I should probably overload it so it will accept it.

 

Why its crashing could be related to how quickly the group gets spawned in and is told to have orders. I'll run some tests on respawned groups with that function to see if I can replicate crashes.

 

 

mist.scheduleFunction(mist.respawnInZone,{'Armor_1', {'zone_1','zone_2', 'zone_3'} , true , 150},timer.getTime() + 10)

 

for some reason the group only respwn in zone_1. I don t know if it is a problem with me not knowing to program or the random number generator or a bug

 

I just did a little test with it and it spawned in other zones, but the randomization was less than stellar. I'm gonna see if I can improve the distribution for a future release.

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

The function doesn't grab the tasks assigned to the route. So what its doing is the group is following its normal route, and then at the end mist.ground.patrol() grabs all of the route points and effectively creates a new route.

 

Ah, that explains all. Is it difficult to implement?

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

Bit of an issue here Grimes that maybe you can help me with.

 

I've implemented some spawning using the CTTS script to bring in some folks at a certain point. They work fine... on the server side. But if the client is in there when the units spawn the client doesn't see them. If they log out and come back in... they are there.

 

Is there something I'm doing wrong?

 

Basically because I have "pause on load" the client is the person who comes in to get the mission started- and actually starts the clock. I'm thinking this may have something to do with it?

"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

Ah, that explains all. Is it difficult to implement?

 

You should be able to create your own route with assorted scripts as part of it and then give it to the function mist.ground.patrolRoute.

 

 

I've implemented some spawning using the CTTS script to bring in some folks at a certain point. They work fine... on the server side. But if the client is in there when the units spawn the client doesn't see them. If they log out and come back in... they are there.

 

 

So are the AI spawning as the player is loading into the server or is the client completely in game when the AI spawn?

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 I've added a time+10 to allow everything to happen (IE: load mist etc)- but the time +10 can't happen without a client. When the client is there for the transition, the spawned units don't appear to the client- however when I look at the server simultaneously, they are there. When I log the client out (me), and back in then the units are there.

 

Specific to your question, the client in question- basically the client who needs to be there so that time can elapse- doesn't see the units generated unless they log out and come back in with the units already generated.


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

Your not doing anything wrong its just broken. The good news is that it appears to already be fixed on the tester version.

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,

 

I have some problem with a couple of mist function.

 

First:

local radar_wp1 = mist.utils.makeVec3GL(trigger.misc.getZone('Zone2').point)

 

throw an error about "can t perform arithmetic on a table". I manage to go past it with

 

local radar_wap1 = mist.utils.zoneToVec3('Zone2')

 

Second:

local radar_wap1 = mist.utils.zoneToVec3('Zone2')

local radar_wap2 = mist.utils.zoneToVec3('Zone3')

mist.groupToRandomPoint(_targetMimgroup,{radar_wap1, radar_wap2})

 

I get the error

 

attempt to index local 'point' (a nil value)

stack traceback:

[C]: ?

[string "C:\Users\rno\AppData\Local\Temp\DCS\/~mis00..."]:3176: in function 'getRandPointInCircle'

[string "C:\Users\rno\AppData\Local\Temp\DCS\/~mis00..."]:3221: in function 'groupToRandomPoint'

[string "C:\Users\rno\AppData\Local\Temp\DCS\/~mis00..."]:32: in function 'onEvent'

[string "Scripts/World/EventHandlers.lua"]:13: in function <[string "Scripts/World/EventHandlers.lua"]:11>

 

What am I doing wrong?

Link to comment
Share on other sites

1. Thats weird, I'll test it out.

 

2. mist.groupToRandomPoint only accepts a table and each variable as a specific name that may or may not be required.

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

 

mist.groupToRandomPoint({group = _targetMimgroup, point = {radar_wap 1, radar_wap2}})

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

Your not doing anything wrong its just broken. The good news is that it appears to already be fixed on the tester version.

 

Interesting little observation. I noticed there for a bit the mission was loading in the MP arena and all the units I wanted to teleport over were in there when the client went in.

 

Then somehow, something happened and it stopped pausing on load. I ended up reloading the scripts folder from the last 63 build update and though it went back to pausing on load, now the units don't teleport anymore.

 

I'm not sure if I ever got any clarification if this was a 1.2.6 issue or a MIST issue? Need the mission to test it out?

"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

  • 2 weeks later...

Grimes must be taking a well needed break. :)

 

I've got some convoys I'm trying to get to random zones- and I've got them all loading on the same trigger- basically time is more (60). They don't all spawn at once... they come in at stepped intervals.

 

I have tested to see if I can load the scripts first before the convoys spawn in and it seemed to work okay...

 

But I keep getting this transport.dll error and for the life of me nobody seems to be able to nail down what it is.

 

Can anyone who knows mist and the scripting shed some light on this problem? I can post the mission here- but it's already posted over in the bugs section (dcsw game crash).

 

Thanks in advance.

 

 

Edit:

 

I had this little mission drummed up to test out my "grouptoRandomZone" scripts while loaded in different orders and it actually started giving me the same error.

 

Basically, all I need to do is start the mission and then go into F10 view. (I'm testing all this on my server with no 3D rendering). The vehicles get the order at Time More (10) and start making their way. In fact they actually start moving in the right direction but when I go to click on one of them the transport.dll error occurs.

 

The mission is attached. Perhaps someone can shed some light? Do have something wrong in the script as it's pretty much just copy and pasted from the wiki.

test1.miz


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

So the error only occurs when you click on one of your vehicle groups?

 

Have you tried to comment out MIST functions were applicable? See if you can narrow it down to something that you're trying to do in MIST?

 

Which version of MIST are you including?

314-я смешанная авиационная дивизия

314th Mixed Aviation Division: The "Fighting Lemmings"- Forums: http://314thsquadron.enjin.com/ - ED Forum Group: http://forums.eagle.ru/group.php?groupid=119

Link to comment
Share on other sites

3.2.. the latest.

 

I thought I had it nailed when I reset the "do script file" with the 3.2 lua- and then I ran the main mission I was working on and it looked like I had it nailed. I ran it for a few hours (sped up) in SP and then tried it in MP... connecting with two of my own client computers and letting it play out.

 

Of course, then it worked for a bit and crashed again.

 

Originally before I had reset the version of MIST I Was using in the "do script file," it suddenly worked enough in that you could click on things and no trouble. I did the same with my other mission... and it worked as well!

 

Now it happens with no input whatsoever (which was closer to what it was doing before.)

 

I guess my only concern is that I call all the mist functions all at once before many of these units are spawned in. I tested that and it didn't seem to be an issue- however perhaps I'm just calling too many at once?

"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

do "respawned" planes now finally attack enemy planes?or are they still only following their assigned waypoints, ignoring other threats?

i tried to build a mission a few days ago, but the respawning plane seemed to ignore me totally...im just wondering, if ive done something wrong, or if its still a bug/missing feature, with mist 3.2

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