Help with changing sides (Full Version)

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



Message


rmunie0613 -> Help with changing sides (5/16/2019 2:52:30 AM)

I am having an issue with the set unit side. Running the following script, only one of the 12 aircraft actually switch sides...not certain why even one would work if there is an issue with the script, but it is always the same one "Vanguard #11"

Below are two separate tries with the LUA responses...attached is the scenario as well...thank you

ScenEdit_SetUnitSide({Side='USN', Name='Cabimas Airfield', newside='Venezuela'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #1', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #1', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #2', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #2', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #3', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #3', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #4', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #4', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #5', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #5', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #6', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #6', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #7', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #7', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #8', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #8', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #9', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #9', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #10', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #10', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #11', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #11', 'Venezuela Intercept'})
ScenEdit_SetUnitSide({Side='USN', Name='Vanguard #12', newside='Venezuela'})
ScenEdit_AssignUnitToMission({'Vanguard #12', 'Venezuela Intercept'})

ERROR: [string "Console"]:3: invalid arguments to method call
>> ScenEdit_SetUnitSide({Side='USN', Name='Cabimas Airfield', newside='Venezuela'})
for i=1,12 do
if ScenEdit_GetUnit({Side='USN', Name="Vanguard #1"..i,}) ~= nil then -- unit # exists
ScenEdit_SetUnitSide({Side='USN', Name="Vanguard #1"..i, newside='Venezuela'}) -- change side
if not ScenEdit_GetSideIsHuman('Venezuela') then -- not human side
ScenEdit_AssignUnitToMission("Venezuela #"..i, "Venezuela Intercept") -- assign mission
end
end
end
ScenEdit_AssignUnitToMission 0 : ,UnitX was not found in the scenario unit list!
>> ScenEdit_SetUnitSide({Side='USN', Name='Cabimas Airfield', newside='Venezuela'})
for i=1,12 do
if ScenEdit_GetUnit({Side='USN', Name="Vanguard #1"..i,}) ~= nil then -- unit # exists
ScenEdit_SetUnitSide({Side='USN', Name="Vanguard #1"..i, newside='Venezuela'}) -- change side
if not ScenEdit_GetSideIsHuman('Venezuela') then -- not human side
ScenEdit_AssignUnitToMission("Vanguard #"..i, "Venezuela Intercept") -- assign mission
end
end
end
ScenEdit_SetUnitSide 0 : ,Can't find Unit 'Cabimas Airfield' on Side 'USN'
>> ScenEdit_SetUnitSide({Side='USN', Name='Cabimas Airfield', newside='Venezuela'})
for i=1,12 do
if ScenEdit_GetUnit({Side='USN', Name="Vanguard #1"..i,}) ~= nil then -- unit # exists
ScenEdit_SetUnitSide({Side='USN', Name="Vanguard #1"..i, newside='Venezuela'}) -- change side
if not ScenEdit_GetSideIsHuman('Venezuela') then -- not human side
ScenEdit_AssignUnitToMission("Vanguard #"..i, "Venezuela Intercept") -- assign mission
end
end
end





Whicker -> RE: Help with changing sides (5/16/2019 4:24:06 AM)

in the first section the first error is line 3 - it tells you that in the error:3

problem is that per the docs the function parameters (really called arguments) are not a table - you just pass in the unit name and mission name separated by a comma, inside parens but without the curly brackets so:
ScenEdit_AssignUnitToMission('Vanguard #1','Venezuela Intercept')

all your mission ones need to have the curlies removed then that part should work.

in the other section which is cleaner you have:
------------------------------------------------------
for i=1,12 do
if ScenEdit_GetUnit({Side='USN', Name="Vanguard #1"..i,}) ~= nil then -- unit # exists
ScenEdit_SetUnitSide({Side='USN', Name="Vanguard #1"..i, newside='Venezuela'}) -- change side
if not ScenEdit_GetSideIsHuman('Venezuela') then -- not human side
ScenEdit_AssignUnitToMission("Venezuela #"..i, "Venezuela Intercept") -- assign mission
end
end
end
------------------------------------------------------

first problem is:
ScenEdit_GetUnit({Side='USN', Name="Vanguard #1"..i,}) --this is on two lines, can't have the 1 - should be Name="Vanguard #"..i
you have a 1 hard coded in the name, and are adding the index number to it, which will give you 11,12,13,14,15,15,16,17,18,19,110,111,112 which is why you got #11 to work, but then it chokes on the next line so you don't get #12.

next problem:
ScenEdit_AssignUnitToMission("Venezuela #"..i, "Venezuela Intercept")

the unit name is Vanguard not Venezuela.

Nice work, that looks pretty interesting, haven't seen anything with the ARES AI in it yet I don't think.




stilesw -> RE: Help with changing sides (5/16/2019 1:25:32 PM)

Ronald,

This format works: ScenEdit_AssignUnitToMission("Spec Ops", "Coalition LZ").

So,it looks the problem is with the "}" inclusion. If you remove those it should work fine.

-Wayne Stiles




rmunie0613 -> RE: Help with changing sides (5/17/2019 2:03:00 PM)

Thank you guys.. after some hours the lines all are a blur to my eyes lol..it is awesome having helpful extra eyes in this forum!




rmunie0613 -> RE: Help with changing sides (5/17/2019 2:07:55 PM)


quote:

ORIGINAL: Whicker

….
Nice work, that looks pretty interesting, haven't seen anything with the ARES AI in it yet I don't think.


The ARES AI (and a horde of other things lol) I am testing in this scenario, which actually began quite tiny but has become my "scenario test tool" for an entire small campaign now.
Thank you.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1