Announcement

Collapse
No announcement yet.

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MIST 4.4.90 error message

    Hello Grimes,


    I'm getting a constant error message when starting the mission using the MIST 4.4.90 version. Could you please check it out?
    Attached Files

    Comment


      Originally posted by Bimbac View Post
      Hello Grimes,


      I'm getting a constant error message when starting the mission using the MIST 4.4.90 version. Could you please check it out?
      Can't reproduce it. Would the mission file happen to be created/modified from outside of the editor at all? Having the mission file that is creating the error would be helpful in this instance.
      The right man in the wrong place makes all the difference in the world.
      Current Projects: Scripting Wiki, Something...
      Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

      Comment


        No, the mission was modified solely by using the Mission Editor. Please check the attached file.
        The mission was created using older MIST version 4.4.88, then upgraded to MIST 4.4.90.
        Attached Files

        Comment


          Thats odd. I guess there is or at least was some mechanism that saves a name of the role within the table. Not entirely sure why it is there. Could be legacy or could be for localization by the game. Checked the editor lua files for it and nothing jumped out. Uploaded a fix to github dev branch.

          BTW, you will need to switch the order of mist and CTLD in your trigger.

          Table from recent mission I made.
          Code:
                  ["roles"] = 
                  {
                      ["artillery_commander"] = 
                      {
                          ["neutrals"] = 3,
                          ["blue"] = 0,
                          ["red"] = 5,
                      }, -- end of ["artillery_commander"]
          Table from your mission.
          Code:
                  ["roles"] = 
                  {
                      ["artillery_commander"] = 
                      {
                          ["name"] = "ARTILLERY CMD",
                          ["blue"] = 2,
                          ["neutrals"] = 0,
                          ["red"] = 2,
                      }, -- end of ["artillery_commander"]
          The right man in the wrong place makes all the difference in the world.
          Current Projects: Scripting Wiki, Something...
          Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

          Comment


            I have tested the mission with the latest dev build 4.4.91, and no problems, all scripts are working the way they are supposed to (maybe even better).


            Thanks for the tip about the script order during the mission start, helped to solve some problems as well.

            Comment


              Hi, im new to Scripting and need help here. Its a little confusing for me..

              So i want to make this... (all naval units)

              Group A has a pre assigned route. I want Group B to spawn near it (preferably random position) and follow group A.


              So far i got this. For group B to spawn near it I could use this (first is the moving zone)

              Code:
              table mist.cloneInZone (Group B, First)
              But im getting an error

              string "table mist.cloneInZone (group B, First)"]:1:=
              expected near "mist"

              So as i understand I can use this functions in this order..

              1.-To clone a group B near my group A with a moving zone attached to it randomly..
              table mist.cloneInZone (string groupName, string zoneName, Boolean disperse, number
              distance)


              2.-To get the position of Group A with..
              table mist.getAvgPoint(table points)

              3.-To get Group B to move to the point i got at #2
              table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed,
              boolean useRoads)


              Maybe repear 2 and 3 every 60 seconds to update position and orders..

              Am i on the right track here?
              A.K.A. Timon -117th- in game

              Comment


                Looks like you might be miss-reading the documentation a bit. This page might help: https://wiki.hoggitworld.com/view/Sc...entation_Guide

                Its formatted like this.

                What is returned the function name(any required input value, any optional input value)

                So with cloneInZone you might have it be something like...
                Code:
                local newGroup = mist.cloneInZone ('Group B', 'First')
                Now its important to remember that the input values have to be in the correct format, from my example above I put Group B and First into quotes. This makes them a string. To use as you did with your example you'd have to declare them as a variable.

                local First = trigger.misc.getZone('First')
                local Group_B = 'Group B'


                1.-To clone a group B near my group A with a moving zone attached to it randomly..
                table mist.cloneInZone (string groupName, string zoneName, Boolean disperse, number
                distance)
                So this is somewhat of a problem due to how moving zones are handled by the game. At least last I checked the zone doesn't actually move, it just uses the radius as a reference to check to see if something is within a given radius of that unit. What you can do is use another function, the one that cloneInZone uses, to do it.

                Code:
                local vars = {clone = true, groupName = 'Group B', radius = 1000}
                vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits())
                local newGroup = mist.teleportToPoint(vars)

                2.-To get the position of Group A with..
                table mist.getAvgPoint(table points)
                If you look carefully at my above example I use mist.getAvgPos which does the same basic thing as getAvgPoint. The difference is getAvgPos accepts a table of unit objects where-as getAvgPoint is a table of points. To get the same value via getAvgPoint the code would look like this:

                Code:
                local gp = Group.getByName('Group A'):getUnits()
                local points = {}
                for i = 1, #gp do
                   table.insert(points, Unit.getPoint(gp[i]))
                end
                local avg = mist.getAvgPoint(points)
                [code]
                3.-To get Group B to move to the point i got at #2
                table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed,
                boolean useRoads)
                [/quote]

                Kind of an oversight on my part is that this function is only meant to be used with ground groups and not ships. But building a ship waypoint is rather simple..


                Code:
                local vars = {clone = true, groupName = 'Group B', radius = 1000}
                vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits())
                local newGroup = mist.teleportToPoint(vars)
                
                local points = {}
                local startPos = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)}
                local leadPos = mist.getLeadPos(newGroup.name)
                
                startPos.x = leadPos.x
                startPos.y = leadPos.z -- 
                
                table.insert(points, startPos)
                
                local dest = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)}
                -- define dest.x and dest.y however you want
                
                table.insert(points, dest)
                mist.goRoute(newGroup.name, points)
                The right man in the wrong place makes all the difference in the world.
                Current Projects: Scripting Wiki, Something...
                Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                Comment


                  Originally posted by Grimes View Post
                  Looks like you might be miss-reading the documentation a bit. This page might help: https://wiki.hoggitworld.com/view/Sc...entation_Guide

                  Its formatted like this.

                  What is returned the function name(any required input value, any optional input value)

                  So with cloneInZone you might have it be something like...
                  Code:
                  local newGroup = mist.cloneInZone ('Group B', 'First')
                  Now its important to remember that the input values have to be in the correct format, from my example above I put Group B and First into quotes. This makes them a string. To use as you did with your example you'd have to declare them as a variable.

                  local First = trigger.misc.getZone('First')
                  local Group_B = 'Group B'




                  So this is somewhat of a problem due to how moving zones are handled by the game. At least last I checked the zone doesn't actually move, it just uses the radius as a reference to check to see if something is within a given radius of that unit. What you can do is use another function, the one that cloneInZone uses, to do it.

                  Code:
                  local vars = {clone = true, groupName = 'Group B', radius = 1000}
                  vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits())
                  local newGroup = mist.teleportToPoint(vars)



                  If you look carefully at my above example I use mist.getAvgPos which does the same basic thing as getAvgPoint. The difference is getAvgPos accepts a table of unit objects where-as getAvgPoint is a table of points. To get the same value via getAvgPoint the code would look like this:

                  Code:
                  local gp = Group.getByName('Group A'):getUnits()
                  local points = {}
                  for i = 1, #gp do
                     table.insert(points, Unit.getPoint(gp[i]))
                  end
                  local avg = mist.getAvgPoint(points)
                  [code]
                  3.-To get Group B to move to the point i got at #2
                  table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed,
                  boolean useRoads)
                  Kind of an oversight on my part is that this function is only meant to be used with ground groups and not ships. But building a ship waypoint is rather simple..


                  Code:
                  local vars = {clone = true, groupName = 'Group B', radius = 1000}
                  vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits())
                  local newGroup = mist.teleportToPoint(vars)
                  
                  local points = {}
                  local startPos = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)}
                  local leadPos = mist.getLeadPos(newGroup.name)
                  
                  startPos.x = leadPos.x
                  startPos.y = leadPos.z -- 
                  
                  table.insert(points, startPos)
                  
                  local dest = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)}
                  -- define dest.x and dest.y however you want
                  
                  table.insert(points, dest)
                  mist.goRoute(newGroup.name, points)
                  [/QUOTE]


                  Thanks!! will read more, but your help is a great start!
                  A.K.A. Timon -117th- in game

                  Comment


                    Hi guys. Can you help me with the lua-predicate in multiplayer mission? I need to make a check in MP for an airplane object:
                    Crash - it hit the ground (Client)
                    Pilot dead - The pilot died (Client)
                    Pilot ejected - The pilot ejected (Client)



                    I understand that this should be done through events.
                    I do not know how?


                    if Object.getByName('PLANE_1') == EVENT.CRASH
                    return true
                    else
                    return false
                    end

                    Comment


                      Originally posted by Hollander View Post
                      Hi guys. Can you help me with the lua-predicate in multiplayer mission? I need to make a check in MP for an airplane object:
                      Crash - it hit the ground (Client)
                      Pilot dead - The pilot died (Client)
                      Pilot ejected - The pilot ejected (Client)



                      I understand that this should be done through events.
                      I do not know how?


                      if Object.getByName('PLANE_1') == EVENT.CRASH
                      return true
                      else
                      return false
                      end
                      You have to add an event handler and check for data based with that event. For example with the crash event: https://wiki.hoggitworld.com/view/DCS_event_crash


                      Code:
                      local function eHandle(event)
                         if event.id == 5 then
                             if event.initiator and event.initiator:getName() then
                                 if mist.DBs.clientsByName[event.initiator:getName()] then 
                                         --that client crashed. 
                                 end 
                             end 
                      
                         end 
                      end
                      
                      mist.addEventHandler(eHandle)
                      Or reverse that slightly, check if there is an initiator and then check if that initiator was a client, then check the event type to do whatever it is you want to do. Its really important with event handlers to check if the objects and different values exist. There are situations where they won't be returned or accessible still.
                      The right man in the wrong place makes all the difference in the world.
                      Current Projects: Scripting Wiki, Something...
                      Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                      Comment


                        I'm having trouble with flagFunc.units_LOS

                        For years it has been working fine with my Moose spawned units, but now I'm spawning a group from two different Moose templates, and whenever the second template is used flagFunc.units_LOS does not work for that group, even though they have the same group name in mission (Alpha #001).

                        Here's the code I'm using

                        Code:
                        mist.flagFunc.units_LOS{ 
                           unitset1 = {'[g]Alpha #001'}, 
                           altoffset1 = 3, 
                           unitset2 = {'[g]Red Target Group#001'}, 
                           altoffset2 = 3, 
                           flag = 100, 
                           interval = 11,
                        toggle = true
                         }
                        Edit: So it seems country related. When the group is spawned from the second template it works if they are from the same country as the first template (US), but not if they are from another country.
                        Edit2: And if I change them all to another country, but the same country, it won't work. Only if they are all US. Weird.
                        Edit3: I've tried just filtering by Blue coalition and it's like these units do not exist for mist.

                        Any idea as to why this is happening, or how I can work around it?
                        Last edited 10-15-2020, 08:29 PM.

                        Comment


                          If you have a small sample mission it would be helpful. Best guess is they aren't getting added to the DB for one reason or another.
                          The right man in the wrong place makes all the difference in the world.
                          Current Projects: Scripting Wiki, Something...
                          Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                          Comment


                            I've got 29773 lines of code, don't know if that's small enough for ya! ;P

                            I'd be embarassed to show you.

                            All jokes aside though, I'll see if I can create a tiny mission only displaying the issue. If this is not recurring then the problem is probably on my end. I found a workaround so I'm good on my end.

                            It would be interesting to find out why it didn't work though. The only two difference between it working and not working, as far as I can see (note I'm no SME) is I have changed the map and factions in the mission by editing the .miz files.

                            Comment


                              Is there any way to manually add units to the unitnametable?

                              Comment


                                The unit name table is just a table indexed numerically.

                                table.insert(tbl, unitName) or tbl[#tbl+1] = unitName would work.
                                The right man in the wrong place makes all the difference in the world.
                                Current Projects: Scripting Wiki, Something...
                                Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                                Comment


                                  Originally posted by Grimes View Post
                                  The unit name table is just a table indexed numerically.

                                  table.insert(tbl, unitName) or tbl[#tbl+1] = unitName would work.
                                  Thanks, I’ll give it a shot!

                                  Comment


                                    Hello everyone. I could use a little assistance. I’m new to all this. I use to build in the ME but am trying my hand at using mist. I am creating a mission where I am using the radio to infinitely spawn in enemy units. I have figured out how to respawn the units using the radio when the unit is dead. What I am trying to figure out is how to spawn the units randomly on the map. Is there a way to do this?

                                    Comment


                                      It depends on how complicated you want to get with it. At a simple level you can use either mist.cloneInZone or mist.respawnInZone for a group and it will randomly spawn those units somewhere within a given zone. Something a bit more complicated would be to use something like mist.getGroupData, figure out a new randomized point however you want, change the coordinates for that group, then spawn it. It'd be something like this:

                                      Code:
                                      local newGroup = mist.getGroupData('whatever')
                                      local newPoint = mist.getRandPointInCircle('whateverPoint', 'whateverRadius')
                                      
                                      for i = 1, #newGroup.units do
                                           newGroup.units[i].x = newGroup.units[i].x + newPoint.x
                                           newGroup.units[i].y = newGroup.units[i].y + newPoint.y
                                      
                                      end
                                      
                                      mist.dynAdd(newGroup)
                                      The right man in the wrong place makes all the difference in the world.
                                      Current Projects: Scripting Wiki, Something...
                                      Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                                      Comment


                                        Thanks Grimes that should get me pointed in the right direction. Another question I have is about using the EWRS for warbirds. I have seen it used on through the inferno and storm of war servers. I did some googling and found the code that was used for it and I copied it in and put to load after mist but it doesn't see enemy. I can use the radio command and f10 and request enemy report but it doesn't see anything. I am not sure how to make it work. if you have any insight on that it would be helpful. thanks again for replying.

                                        Comment


                                          So I put the respawn in zone script and it works good but the enemy units don't fly a particular route. He just spawns in and zooms off to nowhere. I kill and spawn in another and he spawns in a different location like he is supposed to but he goes off in another direction. Is there a script that will make them fly in a certain zone/area/orbit?

                                          Comment

                                          Working...
                                          X