Newby lua Waypoint question

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Newby lua Waypoint question

Post by Parel803 »

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 http://commandlua.github.io/#Waypoint
But I cannot get it working.
Best regards and thank you in advance.
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

I see now I'm behind in version of the game (steam). So that might be the cause. Please delete this report.
regards
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Newby lua Waypoint question

Post by KnightHawk75 »

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?

Code: Select all

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

Thank you. I'm gonna try this evening
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

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
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Newby lua Waypoint question

Post by KnightHawk75 »

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.

Code: Select all

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;
 end
 
 local u = ScenEdit_GetUnit({name='SomeGroupOrUnitname'});
 if (u ~= nil) then
   if (u.type == 'Group') then
     for i,v in pairs(u.group.unitlist) do
      applyWaypoint(v);
     end
   else
     applyWaypoint(u.guid);
   end
 end

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

Going to try again. Thank you for answering.
with regards
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

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

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

The presetThrottle works for all waypoints. But presetDepth not voor the sub.
Atleast on this side.
regards
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

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
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Newby lua Waypoint question

Post by KnightHawk75 »

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

Thank you for you're time and lessons in the lua. Enjoyed it.
with regards
orca
Posts: 545
Joined: Wed Nov 06, 2013 4:59 pm

RE: Newby lua Waypoint question

Post by orca »

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

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'});
table.insert(myNewMLA,{latitude=12.3,longitude=111.0,description='TstLeg3',presetAltitude='low'});
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
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Newby lua Waypoint question

Post by KnightHawk75 »

@Parel803
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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

Thanks for the answer.Should I post it somewhere else or is it oké in this forum?
wit regards GJ
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Newby lua Waypoint question

Post by KnightHawk75 »

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
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Newby lua Waypoint question

Post by Parel803 »

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

Return to “Lua Legion”