Lua assign mission question

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Lua assign mission question

Post by Gunner98 »

Hay guys, I've done this a dozen times or more but getting a strange result here - so it's probably fat finger problems as usual.

Testing a lua command to assign units to a mission - it works - sort of. Looking to assign all 8 Helix to a mission but only the last 5 get assigned. See the clip.

Tried several times with minor changes to syntax but result is the same.

Any thoughts?

Image
Attachments
ASWmsn.jpg
ASWmsn.jpg (120.62 KiB) Viewed 393 times
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Lua assign mission question

Post by michaelm75au »

Can you add a save?
All I can think of is that the names aren't correct. That is there is some character in the name of those first 3 you can't see.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Lua assign mission question

Post by KnightHawk75 »

That would be my guess as well maybe trailing space in the first 3 units, or there are other units on side WP with the exact same names that are getting assigned instead?

To test\find either case, esp the later:

Code: Select all

local u;
 for i=1,8 do;
   u = ScenEdit_GetUnit({Side="WP",Name="38th OShAP #" ..i});
   if u ~=nil then
     ScenEdit_AssignUnitToMission(u.guid,"SAG ASW");
     print('assigned unit named: ' .. u.name .. ' guid: ' ... u.guid);
   else
     print('Failed to find and assign unit: ' .. '38th OShAP #' .. tostring(i));
   end
   u = nil;
 end
 
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Lua assign mission question

Post by Gunner98 »

OK that was the problem - duplicate names! Thanks for the quick response and that was a quick fix.

Appreciate the help.
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Post Reply

Return to “Lua Legion”