Jump to content

Recommended Posts

Posted (edited)

Hi, trying to learn lua scripting to streamline making some more complex missions where triggers can become a cluster. I am not using Mist or Moose, just the default DCS scripting stuff. Open to using either if an easy solution can be found.

I am having with the switch waypoint feature in Lua, every time I try to call it DCS triggers an empty error box. No info on what the issue is as theres no text.

Script I am using:

SwitchWaypoint = { 
   id = 'SwitchWaypoint', 
   params = { 
     fromWaypointIndex = 2,  
     goToWaypointIndex = 4, 
   } 
 } Group.getByName('Aerial-1'):getController():pushTask(SwitchWaypoint)

 

When I run the script it just throws an empty error screen with no context on what the error is. When I try another task like Engage group it works fine. I have ensured the aircraft has enough waypoints so that there is a 4th one to switch too

Secondly, can someone help me understand how the "AI options" work in LUA? They are structured differently from the other tasks, but theres little in the way of examples to follow for someone who is unsure of the syntax. For Example I am trying to manipulate the Radar Using parameter but cant sort out the proper syntax or how to update these options during a mission (IE I want an aircraft to start the mission with its radar off, but turn it on at some point during the mission).

Edited by Chenstrap
Posted
3 hours ago, Chenstrap said:

When I run the script it just throws an empty error screen with no context on what the error is.

Your formatting seems a bit wonky. If above is exactly the script that you are executing you may want to look at the following points:

 

3 hours ago, Chenstrap said:

} Group.getByName('Aerial-1'):getController():pushCommand(Switch)

  • There should be a linefeed or semicolon ";" between the closing curly bracket and Group.GetByName()
  • I see no defined variable "Switch". Did you perhaps mean to write "SwitchWaypoint"?

-ch

Posted (edited)
19 minutes ago, cfrag said:

Your formatting seems a bit wonky. If above is exactly the script that you are executing you may want to look at the following points:

 

  • There should be a linefeed or semicolon ";" between the closing curly bracket and Group.GetByName()
  • I see no defined variable "Switch". Did you perhaps mean to write "SwitchWaypoint"?

-ch

Fixed the mistake with the variable name, but issue persists.

Im purely going off what info I can find on the forum/in the scripting wiki and am basing my formatting off that. Learning as I go really

Im just confused because pushing other task in a similar manner works just fine.

 

For example these work perfectly, and are generally structured the same as the follow parameter (at least the line where the task is pushed):

EngageGroup = { 
  id = 'EngageGroup', 
  params = { 
    groupId = 2,  
    priority = 1 
  } 
}

Group.getByName('Aerial-1'):getController():pushTask(EngageGroup)

local function follow()
nCAP = {"27", "29", "F1", "18", "16", "F5"}
unit = nCAP[math.random(4)]
myGroup = Group.getByName(unit)
selection = Group.getID(myGroup)

 followTask = {
  id = 'Follow',
  params = {
    groupId = selection,
    pos = {x = 200, y = 0, z = -100},
    lastWptIndexFlag = false,
  }    
}

Group.getByName('follower'):getController():pushTask(followTask)

trigger.action.outText(unit, 15)
trigger.action.outText(selection, 15)
 end
 
 follow()

But the switch waypoint task keeps throwing this weird empty error

Edited by Chenstrap
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...