Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Changed some code to fix an error.

 

Grimes, I got an error in the following code at the function 'mistdisplayV3'.

It is related to the following code:

 

 
messageData:remove()  -- now using the remove/destroy function.

 

This is the error that I got in the DCS.log files:

 

 
00186.623 INFO    SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\vandeves\AppData\Local\Temp\DCS\/~..."]:3701: attempt to call method 'remove' (a nil value)

 

I changed your code in the function mistdisplayV3 to the following:

 

 
local function mistdisplayV3() -- adding audio file support
 -- CA roles
 local caMessageRed = false
 local caMessageBlue = false
 local audioRed = false
 local audioBlue = false
 local audioPlaying = false
 if #messageList > 0 then
  
  for messageId, messageData in pairs(messageList) do
   if messageData.displayedFor > messageData.displayTime then
    if messageData ~= nil then
     mist.debug.info( 'mistdisplayV3', 'messageData', messageData )
[color=red]      table.remove(messageList, messageId)
     return true
[/color]     end
    
   --[[else
    if messageData.fileName then
     audioPlaying = true
    end]]
   end
   
   messageList[messageId].displayedFor = messageList[messageId].displayedFor + messageDisplayRate
  end

 

Now the error does not appear again.

 

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

thanks xcom - +1

 

I am using a randomized trigger for AI groups right now so it will randomly span a certain # of AI flights differently each time…. will this script recognize an "unselected" group from my randomization list as "dead" and spawn it? I'm trying to figure out if it will render my randomization efforts as moot then.

 

I'd like to randomize - then respawn out of the groups that were selected by the random triggers.

 

Just so I know what you're asking- you want to generate a certain number of AI flights in the mission and respawn those units... But not the others that aren't spawned in by your random trigger. That's how I'm understanding the question so if my answer doesn't make sense I may have misunderstood.

 

If the unit isn't actually destroyed then it won't respawn. Sounds like you're concerned that if the unit isn't spawned in that it may be detected as destroyed and spawn in its replacement but this will not be a problem.

"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...
Using mist 3.3 and everything working great but one line in the dcs.log that keeps bugging me...

00041.137 INFO    SCRIPTING: mist.scheduleFunction, error in  scheduled function: [string  "C:\Users\user\AppData\Local\Temp\DCS.openbet..."]:4251: Parameter #1  (unit name string) missed
00203.126 INFO    SCRIPTING:  mist.scheduleFunction, error in scheduled function: [string  "C:\Users\user\AppData\Local\Temp\DCS.openbet..."]:4254: Parameter #1  (unit name string) missed

Making these changes to Mist will fix that:

http://forums.eagle.ru/showpost.php?p=2063758&postcount=14

Link to comment
Share on other sites

Just so I know what you're asking- you want to generate a certain number of AI flights in the mission and respawn those units... But not the others that aren't spawned in by your random trigger. That's how I'm understanding the question so if my answer doesn't make sense I may have misunderstood.

 

If the unit isn't actually destroyed then it won't respawn. Sounds like you're concerned that if the unit isn't spawned in that it may be detected as destroyed and spawn in its replacement but this will not be a problem.

 

^^ Bang on ENO - that's exactly what i was worried about.

 

Thanks!

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

hi all,

 

newbie here scripting...

 

How I can send a UH-1H (IA) to pickup a downed pilot ramdonly respawned in zone?

 

I try to use "mist.heli.buildWP" and "mist.GoRoute"with "mist.getLeadPos" inside to locate unit and send the copter, but it returns a error

 

anyone could explain me how can I do it? or its so difficult?

 

Edit: I do it!

 

local path = {}

path[#path + 1] = mist.heli.buildWP(mist.getLeadPos('mia'), TurningPoint, 120, 100, 'agl')

path[#path + 1] = mist.heli.buildWP(mist.getLeadPos('aliado'), TurningPoint, 170, 200, 'agl')

mist.goRoute(Group.getByName('helo'), path)

 

thanks


Edited by Zaz0
Link to comment
Share on other sites

  • 2 weeks later...

Beware of last update... sad problem here: http://forums.eagle.ru/showthread.php?t=125269

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

Mist 3.4

 

Since I was away several issues have apparently cropped up with the scripting engine and these issues have had a negative impact on the sim. I'd like to thank ajax and svenvandevelde for posting workarounds for users in regards to mist and general simulator scripting engine issues.

 

Attached is mist 3.4 which contains fixes for issues highlighted by ajax and svenvandevelde, along with some other changes I did a few months ago. If other issues are discovered I will make the appropriate fixes, however the version number will likely remain "3.4" and I'll just hotfix it. So basically version 3.4 is to fix whatever maybe broken, and new features will be shelved for later iterations. (3.5+)

 

Changelog 3.4.23:

-added country table entry for mist.getGroupData()

-mist.getHeading now accepts optional second variable. Set to true to get cartesian-based heading instead of lat/lon-based heading.

-fixed mist.getLeadPos if passed group table contains a dead leader

-fixed minor bug with msgDisplay (thanks svenvandevelde)

-fixed bug with dynamically added groups (thanks Ajax)

 

Changelog 3.4.24:

-teleportToPoint now accepts vars.gpName or vars.groupName for the groups name

-fixed bug with mist.flagFunc.units_in_polygon() toggle option

 

Changelog 3.4.25:

-Fixed bug with mist.message.add with regard to updating messages

 

 

So please post if you are having issues with 3.4. As far as I can tell Speed is still away/busy so I'll also address issues for slmod. If issues are present in my IADScript I'll also attempt to fix. Please post issues in their respective threads though:

SLmod

IADScript

Mist (Why do you need a link for the mist thread? You are already here!)

 

Right now my priority is mist>slmod>IADScript

Mistv3_4_25.rar


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

+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

  • 2 weeks later...

Issue/byDesign found with MIST DBs -

1. AliveUnits DB does not hold newly spawned units.

2. DBs do not hold infantry units. (DBs categories only have helicopter/plane/ship/static/vehicle)

 

 

- Can the newly spawned units be added to the AliveUnits table?

- Is there a quick way to add another category to the DBs to hold infantry?

 

 

Edit - point 1 was only tested with infantry, might be that it actualy does hold newly spawned units but not infantry because of point 2.

 

Thanks.

Link to comment
Share on other sites

Scusate chiedo cortesemente se posso usare e modificare parte del codice mist per poterlo usare nei miei script,vorrei sapere se e possibile!

 

 

Traslated by Google!

Sorry politely ask if I can use and modify the code mist to use it in my script, I would like to know if it is possible!

 

 

 

 

posto un dei esempi del codice che dovrei usare!

a place of the examples of code that I should use!

function getCountry(groupName)
   local i,j,k
   if env.mission.coalition then
       for coa,coaTable in pairs(env.mission.coalition) do
           if type(coaTable) == 'table' and coaTable.country then
               for i=1,#coaTable.country do
                   local country = coaTable.country[i]
                   for uType,uTable in pairs(country) do
                       if uType == 'helicopter' or uType == 'ship' or uType == 'vehicle' or uType == 'plane' then
                           if type(uTable)=='table' and uTable.group then
                               for j=1,#uTable.group do
                                   local group = uTable.group[j]
                                   if group.units then
                                       for k=1,#group.units do
                                           local unit = group.units[k]
                                           -- if unit.name and unit.name == groupName then
                                               -- return group.name--country.name
                                           -- end
           if group.name and group.name == groupName then
                                               return country.name
                                            end
                                       end
                                   end
                               end
                           end
                       end
                   end
               end
           end
       end
   end
   return nil
end

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Link to comment
Share on other sites

hello - i cannot get the following to work....

 

 

switched condition -> if not Group.getByName('groupA') then

mist.respawnGroup('groupA', 120)

end

 

is the respawn function currently broken in MIST?

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

3.4 but i just figured it out.... i was using a GROUP DEAD condition... apparantly the ME doesnt like this... once i changed it to a flag condition that was set when the group dies, everything worked.

 

eg.

SWITCHED CONDITION -> GROUP DEAD 'GROUP A' -> DO SCRIPT if not Group.getByName('groupA') then

mist.respawnGroup('groupA', 120)

end

 

^^ Doesnt work

 

BUT

SWITCHED CONDITION -> GROUP DEAD 'GROUP A' -> FLAG ON '31'

SWITCHED CONDITION -> FLAG TRUE '31' -> DO SCRIPT if not Group.getByName('groupA') then

mist.respawnGroup('groupA', 120)

end

 

^^ WORKS

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

The mission editor triggers don't update for anything added with coalition.addGroup() which is what mist.respawnGroup() uses. So even if the group data is identical, it won't "see" the group. However the trigger will work if you use a script condition. Also your method works to.

 

For instance: Switched Condition > Lua Predicate (if not Group.getByName('groupA') then return true end) > Do Script (mist.respawnGroup('groupA', 120))

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

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