Newby lua Waypoint question (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion


Parel803 -> Newby lua Waypoint question (4/5/2020 9:16:48 AM)

Apologize in advance for my most likely an operator error.
I can add a waypoint for a unit.
My question is should I be able to add the additional info to that waypoint like speed?
And should I see that back in the F2 info of that waypoint.
Found on the feilds on
But I cannot get it working.
Best regards and thank you in advance.

Parel803 -> RE: Newby lua Waypoint question (4/5/2020 2:20:26 PM)

I see now I'm behind in version of the game (steam). So that might be the cause. Please delete this report.

KnightHawk75 -> RE: Newby lua Waypoint question (4/6/2020 12:31:01 PM)

In case it's not version behind issue - Basically you want to build a new table with all your waypoint data you want assigned for the unit, then swap that table for the current .course table on the unit. Are the desired\preset speed part the problem specifically or just getting it to work in general?

local myNewCourse = {};
table.insert(myNewCourse,{latitude=150.0,longitude=10.0,description='Segment 1'});
table.insert(myNewCourse,{latitude=150.0,longitude=20.0,description='Segment 2'});
table.insert(myNewCourse,{latitude=150.0,longitude=30.0,description='Segment 3',desiredSpeed=350.0});
local u = ScenEdit_GetUnit({name='blalbla'});
u.course = myNewCourse;

Parel803 -> RE: Newby lua Waypoint question (4/6/2020 3:25:30 PM)

Thank you. I'm gonna try this evening

Parel803 -> RE: Newby lua Waypoint question (4/7/2020 7:22:35 AM)

The waypoints worked, thx. I had a SurfaceShip. It checked the box "manual override" but hasn't filled in the desired speed in the appropriate line. Gonna stuggle further this evening.
Another question would be: is it possible to do this for a group (TG)? And if so, which SE should I use.
Thx again
with regards

KnightHawk75 -> RE: Newby lua Waypoint question (4/7/2020 1:22:45 PM)

Hmm, using the desiredSpeed= setting on my install and on an individual unit shows segment3 as having manual speed checked and the 390 speed, not sure why you see different results, though my test were all aircraft.

**That said when I do it for a group, you are correct it doesn't apply the speed settings correctly\as expected.**
That seems like a bug to me, as it always inherits whatever the current group speed settings are for all waypoints, yet does take the throttle preset setting and apply it. I didn't test altitude.

As mentioned yes you can do it for a group, you would use the same se_GetUnit() but use the groupname\groupguid for the unit object, as the group object has it's own .course property table just as you would a singular unit.

One way to get around the speed setting bug is write a function that loops though any given group's member units and apply the waypoints individually to each one.

local function applyWaypoint(uGuid)
 local myNewCourse = {};
 table.insert(myNewCourse,{latitude=150.0,longitude=10.0,description='Segment 1',desiredSpeed=390});
 table.insert(myNewCourse,{latitude=150.0,longitude=15.0,description='Segment 2',desiredSpeed=410.0});
 table.insert(myNewCourse,{latitude=150.0,longitude=20.0,description='Segment 3',desiredSpeed=420.0});
 local u = ScenEdit_GetUnit({guid=uGuid});
 u.course = myNewCourse;

local u = ScenEdit_GetUnit({name='SomeGroupOrUnitname'});
if (u ~= nil) then
  if (u.type == 'Group') then
    for i,v in pairs( do

Doing the above then does seem to also set the group settings to what the individual units all are, strange, maybe it picks it up from which ever unit is 'lead' in a group? I don't know how to determine the lead in LUA since it seems the unit formation property table doesn't provide that information.

Parel803 -> RE: Newby lua Waypoint question (4/7/2020 1:58:50 PM)

Going to try again. Thank you for answering.
with regards

Parel803 -> RE: Newby lua Waypoint question (4/7/2020 3:00:48 PM)

It looks like that I can't get it with "desiredSpeed" on a ship. Same on a Submarine. Have it working on a A/C.

Groups works nic, thx. Same issue, if I'm correct, it works for an air group not for a surface ships group.

I'm new at it so could be an operator error on this end.

with regards

Parel803 -> RE: Newby lua Waypoint question (4/7/2020 3:27:39 PM)

The presetThrottle works for all waypoints. But presetDepth not voor the sub.
Atleast on this side.

Parel803 -> RE: Newby lua Waypoint question (4/7/2020 4:14:56 PM)

Probably not importent but it looks like the presetThrottle for A/C with 'military' is the only one that don't give the right response in F2 and the other waypoints after this one are not in the system.

KnightHawk75 -> RE: Newby lua Waypoint question (4/7/2020 9:06:29 PM)


ORIGINAL: Parel803

It looks like that I can't get it with "desiredSpeed" on a ship. Same on a Submarine. Have it working on a A/C.

On singular ships and subs desiredSpeed does works for me but...
It will not work while ship\sub is member of a group though(unless it's the only member of the group), and only the lead of a group will even take a waypoint when it's a surface group, oddly multiple subs do get waypoints if grouped among themselves. I imagine this is because of all the relative\fixed station bearing logic stuff for surface ship groups overwriting whatever waypoints we set. idk?? The inconsistent treatment is odd and confusing though.

Still bottom line is setting speed on group's waypoints seems broken, and particularly so when it comes to grouped ships\subs where there isn't a good work around - other then not grouping. I didn't have a chance to test the presetDepth settings much but it did appear to take 'Surface' and 'Shallow' etc even though the f2 gui doesn't display it correctly it stays in the waypoint table but I didn't run it long enough to see if it actually followed the instructions.

Parel803 -> RE: Newby lua Waypoint question (4/8/2020 7:22:17 AM)

Thank you for you're time and lessons in the lua. Enjoyed it.
with regards

orca -> RE: Newby lua Waypoint question (4/8/2020 6:05:23 PM)

Edit- sorry posted in wrong tread. Please disregard.

Not sure if the LUA forum or game feature request forum is the best location for this post but I will start here to see what others think....

I frequently have difficulties timing missions/strikes when creating a scenario. Until a possible future strike planner is available, some kind of LUA time trigger script may be helpful to plan strikes/missions.

LUA timetrigger script:
is an action.
when this timetrigger script is triggered, a timer (length of time determined by the user) starts
when this timer ends then the script creates a new trigger that can be used to initiate an event (ie launch strike mission)

possible script variables: timer length, resulting new trigger name

There are several relatively clunky workarounds to accomplish this basic goal of timing, but I think a LUA script like this would be very helpful for scenario designers. I know little about LUA so not sure if this is even possible.

Parel803 -> RE: Newby lua Waypoint question (6/22/2021 8:06:57 AM)

A follow up Question just to confirm, if I may.

I Tried:
local myNewMLA = {};
table.insert(myNewMLA,{latitude='12.2719935992898', longitude='111.929875733348',description='TstLeg2',presetAltitude='High25000'});
local u = ScenEdit_GetUnit({name='F-16AM Falcon MLU', guid='50PVO4-0HM9L8UEF7T5O'});
u.course = myNewMLA;
print (u.course)

The print gives me both preset Altitudes for the WP's
{ [1] = { Description = 'TstLeg2', latitude = 12,2719935992898, TypeOf = 'ManualPlottedCourseWaypoint', longitude = 111,929875733348, PresetAltitude = 'High25000' }, [2] = { Description = 'TstLeg3', latitude = 12,3, TypeOf = 'ManualPlottedCourseWaypoint', longitude = 111, PresetAltitude = 'Low1000' } }

But when clicking on the waypoint in my main screen, the settings doesn't give me the setting filled in. Same in the Unit window under 'unit alt/speed' for the waypoint info.

Just wondering if this is a glitch or correct presented.

The unit is going to the preset altitude, so that works fine.

with regards GJ

added: looks to me the same for desiredAltitudeTF=100. But I realize I might be doing something wrong here.

KnightHawk75 -> RE: Newby lua Waypoint question (6/22/2021 11:49:22 PM)

That's correct it works, but is not showing up in the gui, we probably should report that glitch (i'm thinking it's not intentional). ;)

Parel803 -> RE: Newby lua Waypoint question (6/23/2021 6:28:44 PM)

Thanks for the answer.Should I post it somewhere else or is it oké in this forum?
wit regards GJ

KnightHawk75 -> RE: Newby lua Waypoint question (6/24/2021 1:05:20 AM)


ORIGINAL: Parel803

Thanks for the answer.Should I post it somewhere else or is it oké in this forum?
wit regards GJ

I would post in tech support (not all the devs get a chance to read all these threads for everything discussed), along with a simple stripped down scene, that includes a simple special action that when pressed runs code that demonstrates the issue. That way they can just load it, press it and then check the gui.

Parel803 -> RE: Newby lua Waypoint question (6/25/2021 6:41:24 PM)

Thx I'll try to do so.
with regarsd GJ

Page: [1]

Valid CSS!

Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI